You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: labs/lab-7/src/test/java/pragmatech/digital/workshops/lab7/solutions/SharedPostgresContainerExtension.java
You are to follow a strict test-driven development (TDD) workflow for all code changes. The process is as follows:
4
+
5
+
1. Write Tests First:
6
+
7
+
- Begin by writing comprehensive tests (unit, integration, or end-to-end) that define the expected behavior of the code.
8
+
- Use explicit input/output pairs and edge cases.
9
+
- Do not write any implementation code at this stage, even if the functionality does not yet exist.
10
+
- Confirm that you are only writing tests, not mock implementations.
11
+
12
+
2. Run and Confirm Failing Tests:
13
+
14
+
- Run the tests and confirm that they fail, as the implementation does not exist yet.
15
+
- Do not write or suggest any implementation code at this stage.
16
+
17
+
3. Commit the Tests:
18
+
19
+
Once the tests are complete and you are satisfied with their coverage, commit only the test code.
20
+
21
+
4. Write Implementation Code:
22
+
23
+
- Write the minimal implementation code required to make the tests pass.
24
+
- Do not modify the tests during this step.
25
+
- Iterate: If the tests do not pass, adjust the implementation and rerun the tests until all pass.
26
+
- Optionally, verify with independent subagents or reviewers that the implementation is not overfitting to the tests.
27
+
28
+
5. Commit the Implementation:
29
+
30
+
- Once all tests pass and you are satisfied with the implementation, commit the code changes.
31
+
32
+
33
+
**Guidelines:**
34
+
35
+
- Always keep tests and implementation changes in separate commits.
36
+
- Do not write any implementation code before the tests are written and committed.
37
+
- Do not modify the tests after they are committed, unless explicitly instructed to do so.
38
+
- Be explicit and transparent about each step, confirming completion before moving to the next.
39
+
40
+
**Your goal:** Incrementally build and verify code by iterating between writing tests and writing implementation, ensuring each change is easily verifiable and traceable.
41
+
42
+
## Test Code
43
+
44
+
When writing test code, please follow these guidelines:
45
+
46
+
- Use JUnit 5 for all test classes
47
+
- Name test methods using the pattern: `should<ExpectedBehavior>When<Condition>`
48
+
- Structure each test with the Arrange-Act-Assert pattern
49
+
- Use AssertJ for all assertions
50
+
- Avoid for loops and if statements in tests
51
+
- Avoid comments in the test code
52
+
- Name the class under test variable as cut
53
+
- Create a separate test class for each production class
54
+
- Follow a consistent setup pattern for all tests
55
+
- Use `@DisplayName` for more descriptive test names in reports
56
+
- Group related tests with `@Nested` classes
57
+
- Use parameterized tests for testing multiple scenarios
58
+
- Mock external dependencies with Mockito
59
+
- Use Java records for test data classes
60
+
- When constructing test data for existing domain classes, use the Builder and Object Mother pattern
Copy file name to clipboardExpand all lines: labs/lab-8/README.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,13 @@
1
1
# Lab 8: General FAQ and Customer Specific Issues
2
2
3
+
## AI
4
+
5
+
```
6
+
For my BookController, please implement a new endpoint to export all avialable books as CSV. Include all available fields of the Book and sort it by default by the creation date.
7
+
8
+
Make sure this can only be done by authenticated users with the "ADMIN" role.
9
+
```
10
+
3
11
This lab covers practical topics that frequently come up in real-world Spring Boot testing projects: GitHub Actions pipeline best practices, Maven tips for faster builds, and test organization using JUnit 5 `@Tag` with Maven profiles.
0 commit comments