Issue
I'm testing an app with espresso. The 1st testcase loads data with the 1st activity from the web into a local database. The 2nd test case / 2. Activity shows data from the database.
That's why Testcase 1 needs to run before Testcase 2. But that does not always happen, espresso occasionally changes the order. How can I solve the problem? Can I set the order of the TestCases (Testclasses)?
Solution
You have the following annotation @FixMethodOrder.
You can use it with the following parameter : MethodSorters.NAME_ASCENDING.
The code (an example) :
@RunWith(AndroidJUnit4.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class YourTestClass {
@Test
public void A_Test() {
System.out.println("1");
}
@Test
public void B_Test() {
System.out.println("2");
}
}
You will find more detailed solutions here : [previous answers] (Test order with espresso)
You can do that using the @RunWith annotation. You can have a short look here Aggregating tests in suites. Basically what you have to do is the following :
Edit:
@RunWith(Suite.class)
@Suite.SuiteClasses({
TestFeature1.class,
TestFeature2.class,
TestFeature3.class,
TestFeature4.class
})
public class FeatureTestSuite {
// the class remains empty,
// used only as a holder for the above annotations
}
Answered By - R13mus
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.