Issue
I am trying to run just a single Android test case from the command line.
From the IDE I can just right click and run, but from CLI with the following it fails:
./gradlew test --tests "com.xyz.b.module.TestClass.testToRun"
Error:
> Unknown command-line option '--tests'.
How can I run a single UNIT TEST method? I want to emphasis that I want to run a single unit test, not an instrumentation test from command line.
Update: I have a camera app. Imagine that I have a build variant called usCameraDebug
. (That means united states camera debug) Now can you tell me how to run a single test case i called mySingleTest
?
I tried this as you mentioned: ./gradlew test --tests "*mySingleTest"
and ./gradlew app:usCameraDebug test --tests "*mySingleTest"
and also: ./gradlew app:usCameraDebugUnitTest --tests "*mySingleTest"
but it . does not work. caan you tell me exactly what to type based on my build variant. its in a module called "app" as defaulted.
Here is the test I want to run:
package com.xyz.cameras.parts
@Test
fun mySingleTest(){
assertEquals(12,13)
}
Solution
You need to specify a wildcard in the pattern while looking for the test name, and make sure to use module + flavor. --tests
will not work with ./gradlew test
or ./gradlew check
Try this pattern -> ./gradlew :<module>:<flavor> --tests "*textThatTestNameContains*"
Example ->
./gradlew :profile:testDebug --tests "*my_profile*"
will run this test:
@Test
public void my_profile_pageview()
Additionally, running with --info
flag helps to see the tests themselves or --debug
for more output. e.g.
./gradlew --info :profile:testDebug --tests "*my_profile*"
Answered By - Mark Han
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.