Skip to content

feat: testCompileSafety option to skip compile safety in test compilations - #118

Open
shreknitin89 wants to merge 1 commit into
InsertKoinIO:mainfrom
shreknitin89:feat/test-compile-safety-opt-out
Open

shreknitin89 wants to merge 1 commit into
InsertKoinIO:mainfrom
shreknitin89:feat/test-compile-safety-opt-out

Conversation

@shreknitin89

Copy link
Copy Markdown
Contributor

Problem

Since 1.1.0, full-graph validation runs at every startKoin / koinApplication entry point, and there's no way to scope that by compilation. Test sources are full of entry points, and a unit test typically loads a deliberately partial graph: the module under test plus a few mocks. In our multi-module Android app, 12 unit-test compilations fail with about 52 diagnostics under allWarningsAsErrors (KOIN-W001 modules not loaded, KOIN-D001/KOIN-D003 for mocked dependencies, KOIN-W003 for helper-built lists), while the production graphs compile clean. The only switch today is compileSafety = false for the whole Gradle module, which also turns off validation of the production graph.

Change

Adds koinCompiler { testCompileSafety = false }. The default is true, so existing behavior is unchanged. When it's false, test compilations get compileSafety=false, and main compilations keep whatever compileSafety says. A compilation counts as a test compilation when its name is test or ends in Test (jvmTest, debugUnitTest, debugAndroidTest).

Testing

With this change (on top of #116) built locally as 1.2.1-local and testCompileSafety = false: forge-app and the legacy app module keep full-graph validation (dropping a module from startKoin fails with 545 KOIN-D001s on a non-incremental compile), and every unit-test compilation in the repo compiles clean. There are no Gradle-plugin tests upstream to extend. I'm happy to add a TestKit test if you'd like one.

🤖 Generated with Claude Code

…tions

Since 1.1.0 every startKoin/koinApplication call is a full-graph entry
point, including those in test sources, which usually assemble a partial
graph of the module under test plus mocks. Their entry points then
report KOIN-W001/D001/D003 for bindings the test never needs.
testCompileSafety (default true, unchanged behaviour) lets a build keep
full-graph validation on main compilations and turn it off for test
compilations.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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