Skip to content

Add CI to main#2

Merged
Bondpl merged 19 commits intomainfrom
CI
Apr 19, 2025
Merged

Add CI to main#2
Bondpl merged 19 commits intomainfrom
CI

Conversation

@Bondpl
Copy link
Owner

@Bondpl Bondpl commented Apr 19, 2025

Add CI to automatically run the tests

@Bondpl Bondpl requested a review from Copilot April 19, 2025 18:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +49 to +51
@AfterEach
void tearDown(TestInfo testInfo) {
System.out.println("Test PASSED: " + testInfo.getDisplayName());
Copy link

Copilot AI Apr 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
@AfterEach
void tearDown(TestInfo testInfo) {
System.out.println("Test PASSED: " + testInfo.getDisplayName());
@ExtendWith(TestResultLogger.class)
static class UserServiceTest {
// Test methods remain unchanged

Copilot uses AI. Check for mistakes.
Comment on lines +57 to +59
System.out.println("Test PASSED: " + testInfo.getDisplayName());
}

Copy link

Copilot AI Apr 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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();

Copilot uses AI. Check for mistakes.

@AfterEach
void tearDown(TestInfo testInfo) {
System.out.println("Test PASSED: " + testInfo.getDisplayName());
Copy link

Copilot AI Apr 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
System.out.println("Test PASSED: " + testInfo.getDisplayName());
System.out.println("Test completed: " + testInfo.getDisplayName());

Copilot uses AI. Check for mistakes.
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;
Copy link

Copilot AI Apr 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import 'jdk.jfr.Name' appears to be unused. Removing it can help keep the code clean and avoid potential confusion.

Suggested change
import jdk.jfr.Name;

Copilot uses AI. Check for mistakes.
@Bondpl Bondpl merged commit 7dff6f9 into main Apr 19, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants