Add tests, static analysis and code coverage#131
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive testing infrastructure, static analysis, and code coverage tooling to the ViewBindingPropertyDelegate library. It implements an "infrastructure-first" approach by configuring Gradle convention plugins with Detekt, ktlint, and Kover before adding unit tests for all three library modules, and finally fixing CI pipelines to execute these checks automatically.
Changes:
- Added Detekt (1.23.8), ktlint (14.0.1), and Kover (0.9.7) static analysis and coverage tools via Gradle convention plugin
- Added 19 comprehensive unit tests across vbpd-core (6 tests), vbpd (8 tests), and vbpd-reflection (5 tests) using Robolectric, MockK, and kotlin.test
- Fixed CI workflows by removing
continue-on-error, adding test execution, lint checks, and coverage report uploads
Reviewed changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| gradle/libs.versions.toml | Added version catalog entries for testing and quality tools (Detekt, ktlint, Kover, Robolectric, MockK, JUnit, AndroidX Test) |
| gradle/convetions-plugins/vbpd-library-base/build.gradle.kts | Added dependencies for Detekt, ktlint, and Kover Gradle plugins |
| gradle/convetions-plugins/vbpd-library-base/src/main/kotlin/vbpdconfig.gradle.kts | Applied and configured quality tools in convention plugin; added test options for Robolectric |
| config/detekt/detekt.yml | Created Detekt configuration with rules for complexity, style, and naming conventions |
| vbpd-core/build.gradle.kts | Added test dependencies for JUnit, kotlin.test, MockK, and Robolectric |
| vbpd-core/src/test/kotlin/dev/androidbroadcast/vbpd/LazyViewBindingPropertyTest.kt | Added 4 tests verifying lazy initialization, caching, clearing, and thisRef parameter passing |
| vbpd-core/src/test/kotlin/dev/androidbroadcast/vbpd/EagerViewBindingPropertyTest.kt | Added 2 tests verifying eager binding initialization and instance consistency |
| vbpd/build.gradle.kts | Added comprehensive test dependencies including Fragment testing and RecyclerView |
| vbpd/src/test/kotlin/dev/androidbroadcast/vbpd/ActivityViewBindingPropertyTest.kt | Added 2 tests for Activity lifecycle binding creation and cleanup |
| vbpd/src/test/kotlin/dev/androidbroadcast/vbpd/FragmentViewBindingPropertyTest.kt | Added 2 tests for Fragment lifecycle binding and configuration change handling |
| vbpd/src/test/kotlin/dev/androidbroadcast/vbpd/ViewGroupBindingsTest.kt | Added 2 tests for ViewGroup lazy binding creation and instance caching |
| vbpd/src/test/kotlin/dev/androidbroadcast/vbpd/ViewHolderBindingsTest.kt | Added 2 tests for ViewHolder binding with factory and viewProvider |
| vbpd-reflection/build.gradle.kts | Added test dependencies for reflection module |
| vbpd-reflection/src/test/kotlin/dev/androidbroadcast/vbpd/ViewBindingCacheTest.kt | Added 3 tests verifying cache enable/disable and clearing behavior |
| vbpd-reflection/src/test/kotlin/dev/androidbroadcast/vbpd/ReflectionActivityViewBindingsTest.kt | Added 2 tests verifying CreateMethod enum values |
| vbpd/src/main/kotlin/dev/androidbroadcast/vbpd/internal/VbpdUtils.kt | Removed extraneous blank line (code formatting fix) |
| vbpd-reflection/src/main/kotlin/dev/androidbroadcast/vbpd/ViewBindingPropertyDelegate.kt | Removed extraneous blank line (code formatting fix) |
| vbpd-reflection/src/main/kotlin/dev/androidbroadcast/vbpd/ActivityViewBindings.kt | Fixed formatting: removed extra spaces in package declaration and import |
| .github/workflows/build.yml | Removed continue-on-error, added test execution, lint checks, and coverage report uploads |
| .github/workflows/android.yml | Removed continue-on-error, added comprehensive checks and artifact uploads |
| docs/plans/2026-02-14-tests-and-quality-plan.md | Added detailed implementation plan with 13 tasks |
| docs/plans/2026-02-14-tests-and-quality-design.md | Added design document explaining architecture and tool choices |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
vbpd-reflection/src/test/kotlin/dev/androidbroadcast/vbpd/ReflectionActivityViewBindingsTest.kt
Outdated
Show resolved
Hide resolved
vbpd-reflection/src/test/kotlin/dev/androidbroadcast/vbpd/ReflectionActivityViewBindingsTest.kt
Outdated
Show resolved
Hide resolved
Addressing review commentsComment #1 (use Comment #2 (remove unnecessary |
Plan covers: Detekt + ktlint, Kover, Robolectric + AndroidX Test + MockK, CI fixes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
13 tasks: Detekt, ktlint, Kover setup in convention plugins, tests for vbpd-core/vbpd/vbpd-reflection, CI pipeline fixes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…over), and fix CI - Add Detekt, ktlint, and Kover to convention plugin for all library modules - Add unit tests for vbpd-core (LazyViewBindingProperty, EagerViewBindingProperty) - Add lifecycle tests for vbpd (Activity, Fragment, ViewGroup, ViewHolder) - Add tests for vbpd-reflection (ViewBindingCache, CreateMethod) - Fix minor code style issues (double spaces, extra blank lines) - Update CI pipelines: remove continue-on-error, add test/lint/coverage steps - Add Detekt configuration file (config/detekt/detekt.yml) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tting - Fix test compilation: use mockk<KProperty<*>> instead of invalid ::localVar references - Tune detekt config: ignore overridden empty blocks, disable MaxLineLength (ktlint handles it), disable MatchingDeclarationName and MemberNameEqualsClassName for existing API - Apply ktlint auto-formatting across all modules (trailing commas, body expressions, etc.) - All checks pass: detekt, ktlint, unit tests, kover, lint Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove @RunWith(RobolectricTestRunner) from ReflectionActivityViewBindingsTest as it doesn't use Android APIs (runs faster as pure JVM test) - Replace assert(!=) with assertNotEquals for better error messages Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
continue-on-error, add test execution, lint checks, and coverage report upload stepsTest plan
./gradlew helppasses (catalog validation)./gradlew detekt ktlintCheckpasses./gradlew testDebugUnitTest— all tests pass./gradlew koverHtmlReportgenerates coverage reports./gradlew clean checkpasses end-to-end🤖 Generated with Claude Code