Repository navigation
feature: Add JUnit 5 unit test suite, JaCoCo coverage, and CI - #53
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
- Fix Gradle build (add jdbc + h2 deps missing from build.gradle) - Configure JUnit 5 (junit-jupiter) test task and JaCoCo reporting/verification (>=60% line coverage) - Add 46 deterministic unit tests for TopicService and other pure-logic components (models, TimeClient, controllers) - Add GitHub Actions CI workflow that runs tests and reports coverage
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This repo previously had no automated tests and no CI. This PR establishes a complete unit-testing foundation for the Spring Boot / Java 8 app using the standard stack (JUnit 5 + Gradle) with JaCoCo coverage and a GitHub Actions workflow.
Three things happen here:
build.gradleonly declaredspring-boot-starter-web, so./gradlew buildfailed to compile (Application.javausesJdbcTemplate). Added the JDBC + H2 dependencies (already present inpom.xml) so the Gradle build actually compiles.junit-jupiter) wired viatest { useJUnitPlatform() }, plus the JaCoCo plugin for reporting and ajacocoTestCoverageVerificationgate at 60% line coverage (checkdepends on it).Coverage: before → after
Measured with
./gradlew test jacocoTestReport(JaCoCoLINEcounter).hello.Applicationbootstrap)Per-class line coverage after:
hello.service.TopicServicehello.controller.HelloControllerhello.controller.TopicControllerhello.controller.GreetingControllerhello.model.Topichello.model.Customerhello.model.SimpleTimeClienthello.model.Quote/Value/Greetinghello.declaration.TimeClienthello.Application(main + external HTTP + JDBC bootstrap)The 8 uncovered lines in
TopicServicearecatch (IOException)fallback branches in the NIO file methods and theOptional.get()unhappy path.Applicationis the executable bootstrap (main,RestTemplatecalls to an external quotes API, liveJdbcTemplateDDL) — not pure logic, so it is intentionally out of scope for unit testing.Test strategy
TopicServiceas requested — every pure-logic method is covered:makeDistinctAndSortCharacters,splitAllIdWithColonSelectIDWithJavaKeywordThenSortThenJoin,findIdHavingCharacter, the CRUD list ops, filtering/sorting, and the NIO file methods (findAllFilesInPathAndSort,find*,readFileWithStreamFunction).@Autowiredfields get a realTopicServiceinjected via reflection. File-based methods assert against the checked-intemp.txt/ repo tree, so results are stable in CI.toString,SimpleTimeClientdate/time mutation logic, andTimeClientstatic + default methods (getZoneIdvalid/invalid fallback,getZonedDateTime).jacocoTestCoverageVerificationfails the build below 60% line coverage so coverage can't silently regress.CI
New workflow
.github/workflows/ci.ymlruns on pushes/PRs tomaster: sets up JDK 8 (required by the Gradle 4.6 wrapper), caches Gradle, runs./gradlew clean test jacocoTestReport jacocoTestCoverageVerification, writes a coverage table to the job summary, and uploads the test + JaCoCo reports as artifacts.Verification
Link to Devin session: https://app.devin.ai/sessions/ab4482467b964de7aa27a84660d6758c
Requested by: @matthewguerra-cog
Devin Review