feature: add JUnit test suite and JaCoCo coverage reporting - #78
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
Co-Authored-By: shayan <shayan@cognition.ai>
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
The repo had no tests at all, and couldn't have had any:
pom.xmldeclared<packaging>pom</packaging>, so Maven never compiledsrc/main/java, let alone a test source root. This adds 41 JUnit 4 tests covering every class underhello.*(90% line / 80% branch per JaCoCo) plus a coverage report.Build changes (all in
pom.xml, nosrc/mainbehavior touched):packaging: pom -> jar— the prerequisite for compiling and testing anything.spring-boot-starter-test(test scope) andjacoco-maven-plugin0.8.8 (prepare-agent+reportbound toverify, output attarget/site/jacoco/).maven-surefire-plugin2.22.2,mockito.version4.11.0,byte-buddy.version1.14.9.Test notes worth knowing before reading the diff:
@WebMvcTest(X.class)with@ContextConfiguration(classes = X.class)and a@MockBean TopicService. The narrow context is deliberate: loadingApplicationwould drag in itsJdbcTemplateautowire and theCommandLineRunnerthat calls the (long-dead)gturnquist-quoters.cfapps.ioquote API.ApplicationTestexercisesApplication.run()for real against anEmbeddedDatabaseBuilderH2 datasource assigned to the package-privatejdbcTemplatefield, asserting the 4 seeded customers and the 2first_name = 'Josh'rows — no@SpringBootTest, so no network.TopicService's NIO methods resolvePaths.get("")against the process CWD, which under Surefire is the project basedir. The assertions therefore lean on files that are committed:pom.xmlforfindAllFilesInPathAndSort(),gradlewfor the"grad"prefix search, and the repo'stemp.txtforreadFileWithStreamFunction() == " Hello, this, is, Rehman". Running these tests from a different working directory would fail them.SimpleTimeClient.setDate(int day, int month, int year)delegates toLocalDate.of(day, month, year), i.e. the parameter names are in the wrong order. Left as-is (out of scope); the test calls it assetDate(2020, 5, 15)and asserts against the actual behavior rather than the names.mvn clean verifypasses 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