feat(junit5): add JUnit5 reporter#160
Conversation
|
Great start @Hiro-Chiba,
|
|
Pushed the listener, collector, JSON writer, SPI registration, and the Gradle wrapper. All 28 unit tests pass locally on JDK 17. Planning to continue in separate PRs to keep each focused on a single concern:
Happy to adjust order or scope based on your preferences. Ready for review. |
a8ed7ec to
db69084
Compare
Sets up the JUnit5 reporter directory following the minitest/rspec reporter conventions: - Gradle Kotlin DSL build with Java 17 toolchain and Maven publishing - Canonical schema model classes (TestResult, TestModule, TestCase, TestError) matching src/contracts/schemas/reporterSchemas.ts - ProjectRootResolver per ADR-009 (accepts absolute and relative paths) and ADR-010 (explicit > TDD_GUARD_PROJECT_ROOT > error; no silent cwd fallback) - README skeleton Tests not yet run locally pending Java 17 environment setup. ProjectRootResolverTest covers 8 cases: missing config, explicit path precedence, env var fallback, absolute and relative path handling, and cwd-within-root validation. Refs nizos#67, nizos#80. Design inspired by @jsbattig's listener architecture.
Implements the result capture pipeline for the JUnit5 reporter: - TddGuardListener registers via META-INF/services and writes results on test plan completion. Activates only when TDD_GUARD_PROJECT_ROOT is set so the jar is safe to include on a classpath without opting in. - TestResultCollector groups outcomes by moduleId (fully qualified class name). Pure data layer with no JUnit Platform dependency so it is directly unit-testable. - TestJsonWriter serializes to the canonical schema defined in src/contracts/schemas/reporterSchemas.ts with atomic temp-file write. No external JSON library dependency. Tests: 11 cases for TestJsonWriter (passed/failed/skipped, escaping, atomic write, nested directory creation) and 9 for TestResultCollector (grouping, state extraction, throwable handling, insertion order). Tests not yet run locally pending Java 17 environment setup. Refs nizos#67, nizos#80.
Generated via `gradle wrapper --gradle-version 8.10`. Lets reviewers and CI run `./gradlew test` without installing Gradle globally. Verified on JDK 17.0.18 (Homebrew): all 28 unit tests pass (ProjectRootResolver 8, TestJsonWriter 11, TestResultCollector 9).
db69084 to
70e33cd
Compare
|
Hi @Hiro-Chiba, Looking good! I noticed a gap in testing for TddGuardListener, did the test file slip through? Let's address this before merging. We can also look into adding the test factory and integration tests in follow-up PRs. I rebased the branch to pick up the new fixes on main so your checks don't fail. On a side note, I started a new project that I would like to discuss with you if you're interested. Reach me by email, you'll find it in the commit details. :) |
Injects envAccessor into TddGuardListener so the activation check is testable without depending on System.getenv. The public SPI constructor still delegates to System::getenv. Seven test cases covering: - no-op when env var is unset or empty - test.json written when configured - passed, failed (with error message), and skipped capture - container events ignored (only test-level events recorded) - graceful disable when project root is invalid Addresses review feedback from @nizos on nizos#160.
|
Thanks @nizos! Added TddGuardListenerTest with 7 unit tests covering activation, result capture, and graceful disable. Also refactored the listener to inject the env accessor for testability. Planning to add the test factory and integration tests in follow-up PRs. I sent you an email, looking forward to hearing about the project! |
Summary
Introduces a JUnit5 reporter at
reporters/junit5/following the canonical test.json schema. Draft opened after initial scaffolding to confirm direction before implementing the listener logic.Questions for @nizos
io.github.nizosas a placeholder. Preference?tdd-guard-kotestlater?Refs #67, #80.