Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test order with espresso

Is there a way to set test running order in android?
I use Espresso framework and need to test a lot of activities and transitions between them. I want to write different test for those activities, but I need a specific order for running those tests.

like image 900
mr. Nutscracker Avatar asked Aug 14 '14 12:08

mr. Nutscracker


People also ask

How do you assert Espresso?

check is a method which accepts an argument of type ViewAssertion and do assertion using passed in ViewAssertion object. matches(withText(“Hello”)) returns a view assertion, which will do the real job of asserting that both actual view (found using withId) and expected view (found using withText) are one and the same.

Is Espresso unit test?

Use Espresso to write concise, beautiful, and reliable Android UI tests. The core API is small, predictable, and easy to learn and yet remains open for customization.

What is Espresso UI test?

Espresso is an open source android user interface (UI) testing framework developed by Google. The term Espresso is of Italian origin, meaning Coffee. Espresso is a simple, efficient and flexible testing framework.


1 Answers

espresso set running order of tests

From Junit 4.11 comes with @FixMethodOrder annotation. Instead of using custom solutions just upgrade your junit version and annotate test class with FixMethodOrder(MethodSorters.NAME_ASCENDING). Check the release notes for the details.

Here is a sample:

import org.junit.runners.MethodSorters;  import org.junit.FixMethodOrder; import org.junit.Test;  @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class SampleTest {     @Test    public void A_firstTest() {       System.out.println("first");    }     @Test    public void B_secondTest() {       System.out.println("second");    } } 
like image 111
Shivaraj Patil Avatar answered Sep 23 '22 11:09

Shivaraj Patil