Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
489 views
in Technique[技术] by (71.8m points)

Junit5 testSuite with SelectClasses not working in android unit test

i am trying to create a test suite for Unit test of android application, but it always fails with different kinds of configuration error, one among that is as follows,

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':appModules:factList:testDebugUnitTest'.
> No tests found for given includes: [reprator.wipro.factlist.FactListTestSuite] 
 (filter.includeTestsMatching)

RepoDetails: https://github.com/TheReprator/Wipro/tree/junit5

Branch: junit5

TestSuite Class: https://github.com/TheReprator/Wipro/blob/junit5/appModules/factList/src/test/kotlin/reprator/wipro/factlist/FactListTestSuite.kt

I had tried many efforts and references, some of them are as follows,

  1. Link 1
  2. Link 2

My whole code works perfectly with junit4 in master branch.

Please assist.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...