android / android/app-bundle-samples

Tests in dynamic feature module fail when run through gradle command line

Open
#11 39 comments 18 reactions 1 assignee Claimed by @chrisjenx View on GitHub
migrated googlesamples
Dominant language
C++
Stars
735
Forks
348
PR merge metrics
No merged PRs in 30d

Description

I wrote some tests for a Dynamic Feature Module inside `DynamicFeature/src/test/java/my/package/MyTest.kt`. These tests rely on a class that is hosted in the main `app` module. If I run the tests using the Android Studio configuration they run without problems, but on the other hand if I use `./gradlew test` they fail saying that the class on the main module can't be found:
```
java.lang.NoClassDefFoundError
Caused by: java.lang.ClassNotFoundException
```

In order to include the tests inside my CI, I would need either to know how to get the command line order that Android Studio is using, or figure out why when running the gradle task, it is not able to find the main module app.

Any help appreciated.
Thanks in advance!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.