Skip to content

feature: add JUnit test suite and JaCoCo coverage reporting - #78

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1787781784-add-test-coverage
Open

devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1787781784-add-test-coverage

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Aug 26, 2026

Copy link
Copy Markdown

Summary

The repo had no tests at all, and couldn't have had any: pom.xml declared <packaging>pom</packaging>, so Maven never compiled src/main/java, let alone a test source root. This adds 41 JUnit 4 tests covering every class under hello.* (90% line / 80% branch per JaCoCo) plus a coverage report.

Build changes (all in pom.xml, no src/main behavior touched):

  • packaging: pom -> jar — the prerequisite for compiling and testing anything.
  • spring-boot-starter-test (test scope) and jacoco-maven-plugin 0.8.8 (prepare-agent + report bound to verify, output at target/site/jacoco/).
  • Pins needed to run tests on a modern JDK, since the Spring Boot 2.0.2 defaults predate it: maven-surefire-plugin 2.22.2, mockito.version 4.11.0, byte-buddy.version 1.14.9.

Test notes worth knowing before reading the diff:

  • Controllers use @WebMvcTest(X.class) with @ContextConfiguration(classes = X.class) and a @MockBean TopicService. The narrow context is deliberate: loading Application would drag in its JdbcTemplate autowire and the CommandLineRunner that calls the (long-dead) gturnquist-quoters.cfapps.io quote API.
  • ApplicationTest exercises Application.run() for real against an EmbeddedDatabaseBuilder H2 datasource assigned to the package-private jdbcTemplate field, asserting the 4 seeded customers and the 2 first_name = 'Josh' rows — no @SpringBootTest, so no network.
  • TopicService's NIO methods resolve Paths.get("") against the process CWD, which under Surefire is the project basedir. The assertions therefore lean on files that are committed: pom.xml for findAllFilesInPathAndSort(), gradlew for the "grad" prefix search, and the repo's temp.txt for readFileWithStreamFunction() == " Hello, this, is, Rehman". Running these tests from a different working directory would fail them.
  • SimpleTimeClient.setDate(int day, int month, int year) delegates to LocalDate.of(day, month, year), i.e. the parameter names are in the wrong order. Left as-is (out of scope); the test calls it as setDate(2020, 5, 15) and asserts against the actual behavior rather than the names.

mvn clean verify passes with 41 tests, 0 failures, 0 skips.

Devin-Org: engineering

Link to Devin session: https://app.devin.ai/sessions/4c5fa48440e44d848e7d5554fbda3d8f
Requested by: @shayanshafii


Devin Review

Status Commit
⚪ Not started

Run Devin Review

Devin Review (Staging)

Co-Authored-By: shayan <shayan@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

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.

1 participant