Junit5 Testsuite With Selectclasses Not Working In Android Unit Test
Solution 1:
I see you are using @RunWith(JUnitPlatform::class)
which basically says "hey, please JUnit5, run my JUnit 4 tests!" but then you have used org.junit.jupiter.api.Test
annotation, which tells the platform that those are JUnit5 tests.
So actually, there are no JUnit 4 tests to run.
I'd suggest you to drop the Suite at all and if you want test suites use nested classes. Or use Tag
annotation to group tests.
By default, JUnit5 will run all @Test
methods you have in the test src path. Check your gradle config for those.
Solution 2:
Are you using gradle to run your tests? Because I downloaded your branch, played a little bit to setup an environment without android studio (my personal computer has no dev environment installed) and I got this output on your JUnit 5 branch:
./gradlew appModules:factList:test --rerun-tasks
FactListDataRepositoryImplTest > get fact list from server, on internet connection available() PASSED
FactListDataRepositoryImplTest > No internet available() PASSED
FactListApiServiceTest > get fact list request check() PASSED
FactListApiServiceTest > Timeout example() PASSED
FactListApiServiceTest > get fact list successfully() PASSED
FactListRemoteDataSourceImplTest > fetch list successfully from server and map it to UI pojo() PASSED
FactListRemoteDataSourceImplTest > fetch list failed witherrorBody() PASSED
FactListMapperTest > create the parsed json fact into FactModals classwithtitle() PASSED
FactListUseCaseTest > fetch factlist from remote data source() PASSED
FactListUseCaseTest > failed to load data, as internet isnotavailable() PASSED
FactListViewModalTest > onRefresh, getlist successfully() PASSED
FactListViewModalTest > retry, getFactlist successfully() PASSED
FactListViewModalTest > get factList fetch failed onlaunch() PASSED
FactListViewModalTest > get factList successfully onlaunch() PASSED
...
> Task :appModules:factList:testReleaseUnitTest
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
FactListDataRepositoryImplTest > get fact list from server, on internet connection available() PASSED
FactListDataRepositoryImplTest > No internet available() PASSED
FactListApiServiceTest > get fact list request check() PASSED
FactListApiServiceTest > Timeout example() PASSED
FactListApiServiceTest > get fact list successfully() PASSED
FactListRemoteDataSourceImplTest > fetch list successfully from server and map it to UI pojo() PASSED
FactListRemoteDataSourceImplTest > fetch list failed witherrorBody() PASSED
FactListMapperTest > create the parsed json fact into FactModals classwithtitle() PASSED
FactListUseCaseTest > fetch factlist from remote data source() PASSED
FactListUseCaseTest > failed to load data, as internet isnotavailable() PASSED
FactListViewModalTest > onRefresh, getlist successfully() PASSED
FactListViewModalTest > retry, getFactlist successfully() PASSED
FactListViewModalTest > get factList fetch failed onlaunch() PASSED
FactListViewModalTest > get factList successfully onlaunch() PASSED
Maybe you need to delegate build actions to gradle (it is possible on IntelliJ, not sure on Android Studio) or clear your project settings or something like that.
Probably you are trying to use a Run Configuration
that runs your suite, which is a JUnit4 Suite and expects JUnit4 tests but your tests are JUnit5 tests.
Post a Comment for "Junit5 Testsuite With Selectclasses Not Working In Android Unit Test"