Skip to content Skip to sidebar Skip to footer

Espresso 2.1 Doesn't Find My Tests

I have looked through all the questions on stack I found with similar problem, but none has given me an answer that actually work (https://stackoverflow.com/search?q=espresso+empty

Solution 1:

I managed to reproduce your situation by setting the wrongandroid.test.InstrumentationTestRunner in the test configuration.

I would suggest checking if you have the correct one -android.support.test.runner.AndroidJUnitRunner- (or none) specified in the Run menu | Edit Configurations.

Also, your question's title is somewhat confusing, since from the build gradle dependencies, my understanding is that you're actually going for Espresso 2.1. If that is true, also note that:

TestCases like ActivityInstrumentationTestCase2 or ServiceTestCase are deprecated in favor of ActivityTestRule or ServiceTestRule.

As it can also be seen here or here, the annotations are to be used in the following way: (will adjust your deprecated test class just because I'm nice)

//annotate JUnit4 test classes with@RunWith(AndroidJunit4.class)
@LargeTest
public class FirstActivityTest {

//use the following annotation and declare an ActivityTestRule for your activity under test@Rule
public ActivityTestRule<FirstActivity> mActivityRule = new ActivityTestRule(FirstActivity.class);

//use @Before to setup your test fixture@Before
public void setUp() { ... }

//annotate all test methods with@Test
public void testHelloWorld() { ... }

//release resources by using@After
public void tearDown() { ... }
}

More on Rules

Other great place to find out more about test size annotations

Solution 2:

Maybe this will help someone in the future: if you get a "no space left on device" error while installing the Android stuff, you have to re-install everything.

(If your disk was not full of almost full during installation, don't read it.)

I had a similar issue, the test were not run. The reason was that the announced memory requirements for the Android studio did not include the components required for testing. (And BTW you need not just 2G, but 2G in /tmpand 2G in your home directory.) Now, when the disk memory is exhausted, you get an installation that does not work. After you clear some additional space and re-run the installer, it still does not work. You have to remove everything, clear ~/.AndroidStudio1.5 (because after removal of the software it just wastes precious space), and re-install. (Most likely, they download .zip archives and do not check the result. Even if they considered md5 checking too complex, they still could check the file length! But they do not.)

To print memory usage in a directory under Linux, use du -h -d 1 (or du -h -d 2 for 2 directory levels, -h stands for human-readable).

Post a Comment for "Espresso 2.1 Doesn't Find My Tests"