I tried run Parameterized Unit Test as below in Android Studio.
import android.test.suitebuilder.annotation.SmallTest;
import junit.framework.TestCase;
i
I was also facing the same problem. In My case, I am using JUnit 5 with gradle 6.6. I am managing integration test-cases in a separate folder call integ. I have to define a new task in build.gradle file and after adding first line -> useJUnitPlatform()
, My problem got solved
I made the mistake of defining my test like this
class MyTest {
@Test
fun `test name`() = runBlocking {
// something here that isn't Unit
}
}
That resulted in runBlocking
returning something, which meant that the method wasn't void and junit didn't recognize it as a test. That was pretty lame. I explicitly supply a type parameter now to run blocking. It won't stop the pain or get me my two hours back but it will make sure this doesn't happen again.
class MyTest {
@Test
fun `test name`() = runBlocking<Unit> { // Specify Unit
// something here that isn't Unit
}
}
To add to already great and easy solution provided by Przemek315, the same config if you use Kotlin DSL:
tasks.test {
useJUnitPlatform()
}
If you are using intellij and want to use gradle you need to add this to the dependencies section of build.gradle file:
testImplementation("org.junit.jupiter:junit-jupiter-api:5.4.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.4.2")
Steps:
For me it worked when I've added @EnableJUnit4MigrationSupport
class annotation.
(Of course together with already mentioned gradle libs and settings)