Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds continuous integration to automatically run tests on pushes and pull requests, ensuring that test failures are caught early. Key changes include updates to test files with added tearDown methods, a correction to method naming in RatingServiceTest, and the introduction of a new GitHub Actions workflow.
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/service/UserServiceTest.java | Added tearDown method that logs test results |
| src/test/java/service/TransactionServiceTest.java | Added tearDown method and replaced specific imports; note the unused jdk.jfr.Name import |
| src/test/java/service/RatingServiceTest.java | Added tearDown method and updated method call casing |
| src/main/java/cz/cvut/fit/tjv/social_network/server/controllers/BookController.java | Removed redundant comments in controller methods |
| .github/workflows/ci.yml | Introduced a new CI workflow for building and testing using GitHub Actions |
Files not reviewed (1)
- src/main/resources/application.properties: Language not supported
| @AfterEach | ||
| void tearDown(TestInfo testInfo) { | ||
| System.out.println("Test PASSED: " + testInfo.getDisplayName()); |
There was a problem hiding this comment.
The tearDown method prints 'Test PASSED' unconditionally, which can be misleading if a test fails. Consider using a TestWatcher extension or similar mechanism to accurately report test outcomes.
| @AfterEach | |
| void tearDown(TestInfo testInfo) { | |
| System.out.println("Test PASSED: " + testInfo.getDisplayName()); | |
| @ExtendWith(TestResultLogger.class) | |
| static class UserServiceTest { | |
| // Test methods remain unchanged |
| System.out.println("Test PASSED: " + testInfo.getDisplayName()); | ||
| } | ||
|
|
There was a problem hiding this comment.
The tearDown method in TransactionServiceTest always logs a 'PASSED' message regardless of the test result. Consider implementing a mechanism to only log a pass when the test truly succeeds.
| System.out.println("Test PASSED: " + testInfo.getDisplayName()); | |
| } | |
| // Test result logging is handled by the TestWatcher | |
| } | |
| @TestWatcher | |
| class LoggingTestWatcher extends TestWatcher { | |
| @Override | |
| protected void testSuccessful(ExtensionContext context) { | |
| System.out.println("Test PASSED: " + context.getDisplayName()); | |
| } | |
| @Override | |
| protected void testFailed(ExtensionContext context, Throwable cause) { | |
| System.out.println("Test FAILED: " + context.getDisplayName()); | |
| } | |
| } | |
| @RegisterExtension | |
| LoggingTestWatcher loggingTestWatcher = new LoggingTestWatcher(); |
|
|
||
| @AfterEach | ||
| void tearDown(TestInfo testInfo) { | ||
| System.out.println("Test PASSED: " + testInfo.getDisplayName()); |
There was a problem hiding this comment.
Logging 'Test PASSED' in the tearDown method may cause confusion if tests fail. Consider using a more accurate logging mechanism to reflect the true test outcome.
| System.out.println("Test PASSED: " + testInfo.getDisplayName()); | |
| System.out.println("Test completed: " + testInfo.getDisplayName()); |
| import cz.cvut.fit.tjv.social_network.server.service.UserService; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import jdk.jfr.Name; |
There was a problem hiding this comment.
The import 'jdk.jfr.Name' appears to be unused. Removing it can help keep the code clean and avoid potential confusion.
| import jdk.jfr.Name; |
Add CI to automatically run the tests