Android Testing Instrumentals

Asked

Viewed 180 times

0

When I start to elaborate the instrumental test for Mainactivity it gives error because it does not recognize this Class (Mainactivity), as it is possible to verify in the following image.

inserir a descrição da imagem aqui

I read in some places that "As instrumented tests are compiled into an APK (separate from the application’s APK), they must have their own Androidmanifest.xml file". I don’t know if this is the cause of my problem.

I wonder if you could help me?

1 answer

0

I believe you’ve declared your test class wrong and the right thing would be this:

@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainActivityTest {
    @Rule
    public ActivityTestRule<MainActivity> mMainActivityTestRule =
            new ActivityTestRule<MainActivity>(MainActivity.class);

    @Test
    public void testeAlgo() {
        // Algum teste
    }
}

OBS1: I never had to declare my own manifesto for testing.

OBS2: The package declaration has a strange spacing in the name.

This link has a great test tutorial: https://codelabs.developers.google.com/codelabs/android-testing/index.html

  • I tested as you suggested and continues to give an error, says that can not find Mainactivity @Márcio Oliveira

  • The error you give me can be seen here https://answall.com/questions/230672/testes-instrumentais-android-studio @Márcio Oliveira

Browser other questions tagged

You are not signed in. Login or sign up in order to post.