Skip to content

Add tests, static analysis and code coverage#131

Merged
kirich1409 merged 5 commits intomasterfrom
develop
Feb 14, 2026
Merged

Add tests, static analysis and code coverage#131
kirich1409 merged 5 commits intomasterfrom
develop

Conversation

@kirich1409
Copy link
Collaborator

Summary

  • Add Detekt static analysis, ktlint code formatting, and Kover code coverage to Gradle convention plugin for all library modules
  • Add comprehensive unit tests for all 3 modules: vbpd-core (6 tests), vbpd (8 tests), vbpd-reflection (5 tests)
  • Fix CI pipelines: remove continue-on-error, add test execution, lint checks, and coverage report upload steps
  • Fix minor code style issues in existing source code

Test plan

  • Verify ./gradlew help passes (catalog validation)
  • Verify ./gradlew detekt ktlintCheck passes
  • Verify ./gradlew testDebugUnitTest — all tests pass
  • Verify ./gradlew koverHtmlReport generates coverage reports
  • Verify ./gradlew clean check passes end-to-end
  • Verify CI runs successfully on this PR

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings February 14, 2026 18:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kirich1409
Copy link
Collaborator Author

Addressing review comments

Comment #1 (use assertNotEquals instead of assert):
✅ Fixed in commit d4298eb. Replaced assert(CreateMethod.BIND != CreateMethod.INFLATE) with assertNotEquals(CreateMethod.BIND, CreateMethod.INFLATE) for better error messages and consistency.

Comment #2 (remove unnecessary @RunWith(RobolectricTestRunner)):
✅ Fixed in commit d4298eb. Removed Robolectric annotation — this test only checks enum values and now runs as a pure JVM test.

kirich1409 and others added 5 commits February 14, 2026 23:49
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>
@kirich1409 kirich1409 merged commit 6c64a93 into master Feb 14, 2026
3 checks passed
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.

2 participants