1

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
  • 1
    gradle command. stackoverflow.com/questions/22505533/… Commented 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. Commented 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.. Commented Oct 6, 2023 at 17:05

1 Answer 1

0

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'
}
Sign up to request clarification or add additional context in comments.

3 Comments

After adding this in build.gradle. How to execute this script. On using ./gradlew test in terminal will trigger this?
@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.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.