[QA] Add Unit Tests for Server Services and Controllers - #73
Conversation
…s and enabling JWT settings
…Utils for improved testing capabilities
…, login, profile management, and bookmarking functionality
…n, skill retrieval, and user search functionalities
…hance coverage and validate functionalities
…overage and validate functionality
…for gateway service
There was a problem hiding this comment.
Pull Request Overview
Adds comprehensive unit tests across user, gateway, and course services, integrates JaCoCo coverage in builds, and updates CI workflows to generate and upload test coverage reports.
- Introduce extensive Mockito-based tests for service and controller layers in all three modules.
- Configure JaCoCo in each module’s Gradle build and refine application-test.yml for mocks and logging.
- Update GitHub Actions workflows to run tests with coverage, verify coverage, and upload reports as artifacts.
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| server/skillforge-user/src/test/resources/application-test.yml | Simplify test profile, add JWT settings, adjust logging levels |
| server/skillforge-user/src/test/java/com/gitittogether/skillForge/server/user/config/TestConfig.java | Add primary beans to mock repositories, encoders, and JWT utils |
| server/skillforge-user/build.gradle | Apply JaCoCo plugin, configure reports and coverage verification |
| .github/workflows/build-and-test-server.yml | Enhance CI to build with coverage, upload artifacts |
| server/skillforge-course/src/main/java/com/gitittogether/skillForge/server/course/controller/courses/CourseController.java | Add @Valid to request bodies for create/update endpoints |
Comments suppressed due to low confidence (3)
server/skillforge-user/src/test/java/com/gitittogether/skillForge/server/user/config/TestConfig.java:28
- Missing import for JwtUtils in TestConfig. Add
import com.gitittogether.skillForge.server.user.config.JwtUtils;to ensure this compiles.
public JwtUtils jwtUtils() {
server/skillforge-course/src/test/java/com/gitittogether/skillForge/server/course/config/TestConfig.java:28
- Missing import for JwtUtils in TestConfig. Add
import com.gitittogether.skillForge.server.course.config.JwtUtils;to avoid compilation errors.
public JwtUtils jwtUtils() {
server/skillforge-user/src/test/java/com/gitittogether/skillForge/server/user/UserServiceImplTest.java:447
- [nitpick] This test duplicates the earlier
shouldBookmarkCourseSuccessfullycase. Consider removing or merging to reduce redundancy and simplify the test suite.
void shouldBookmarkCourseSuccessfully_service() {
…and course services in CI workflow
…readability and precision
…missed and covered line counts
mahdibayouli
left a comment
There was a problem hiding this comment.
Approved! CI/CD-compatible unit tests and coverage reporting added across all services 🚀🚀
🚀 PR Summary: Add Unit Tests, Controller Coverage, and CI Integration
✅ What's Implemented
🧪 User Service Tests
UserServiceImplUserController📘 Course Service Tests
CourseServiceImplCourseController🌐 Gateway Tests
JWTUtilslogicLoggingGlobalFilter🛠 Workflow & Coverage Enhancements
🧰 Adapted build and test GitHub Actions workflows for:
user-servicecourse-servicegateway📊 Test Coverage Reporting
🎯 Goal
Ensure core service logic and controllers are properly tested and integrated with CI/CD to maintain stability and enable scalable feature development.