I'm trying to execute two test methods, one of which is a junit and the other is an Android Test in a sequential manner. The first junit test method will be executed, followed by an Android Test. I don't want to execute it manually, and is there any way to achieve this?
3
-
1gradle command. stackoverflow.com/questions/22505533/…JakeB– JakeB2023-10-02 19:36:55 +00:00Commented Oct 2, 2023 at 19:36
-
A bit off topic, but why does the order matter? Generally tests should be able to run in arbitrary order, especially JUnit and instrumentation tests.E.M.– E.M.2023-10-05 21:31:44 +00:00Commented Oct 5, 2023 at 21:31
-
I have a scenario, I need to execute shell script (CURL) from junit to trigger notification (POST call) and use Instrument test to tap the notification from Notification tray. Its kind of integration testing..Maverick– Maverick2023-10-06 17:05:23 +00:00Commented Oct 6, 2023 at 17:05
Add a comment
|
1 Answer
I consider Gradle build script would work for you. It can be used to specify the order in which the test methods should be executed:
test {
include '**/JunitTest.class'
include '**/AndroidTest.class'
}
3 Comments
Maverick
After adding this in build.gradle. How to execute this script. On using ./gradlew test in terminal will trigger this?
Zufar Sunagatov
@Maverick Yes, using ./gradlew test in the terminal will trigger the test scripts you added to your build.gradle file. Gradle will execute the test scripts in the order that they are specified in the build file.
Maverick
No. When I add test method in build.gradle, I'm getting build error. A problem occurred evaluating project ':app'. > Could not find method test() for arguments [build_aroj2w6mjnkhyiftgvds6h2ax$_run_closure2@1da9d1b5] on project ':app' of type org.gradle.api.Project.