mannodermaus / android-junit5

Testing with JUnit 5 for Android.
Apache License 2.0
868 stars 52 forks source link

How to use android command: am instrument to run testcase if testcase writed in main directory rather than test directory? #360

Open yanweishr opened 5 days ago

yanweishr commented 5 days ago

I write testcase in main dictory rather than test dictory , and run testcase with :adb shell am instrument xxx, then it report error:"Caused by: java.lang.IllegalArgumentException: Could not find extra class de.mannodermaus.junit5.AndroidJUnit5Builder" And I found out that the android-test.apk include the AndroidJUnit5Builder.class ,but the release.apk didnot include the AndroidJUnit5Builder.class, the plugin do something to pack the class to apk file.

So is there a way to use am instrument commond to run junit5 testcase ?

mannodermaus commented 5 days ago

It's possible that this sort of unusual use case isn't supported from the Android side, which is why it won't pick up anything outside androidTest for running as an instrumentation test. Are you saying that you can write testcases in the main directory with JUnit 4, but it doesn't work with JUnit 5? Or is this a general question about how to make this use case work? (If it's the latter, then I'm afraid we can't do anything about it since the Android instrumentation itself would need to be changed first).

yanweishr commented 2 days ago

In fact, this project provides a plugin for users to use. The plugin packs the junit5 library internally. Can it be packed as an aar ,so that users can directly use the aar in the project?