mercredi 28 octobre 2015

importing correct AssertThat method for Robolectric Test

I am attempting to run the test from Robolectric.org's Writing Your First Test page. The test in question looks like this:

  @Test
  public void clickingLogin_shouldStartLoginActivity() {
    WelcomeActivity activity = Robolectric.setupActivity(WelcomeActivity.class);
    activity.findViewById(R.id.login).performClick();

    Intent expectedIntent = new Intent(activity, WelcomeActivity.class);
    assertThat(shadowOf(activity).getNextStartedActivity()).isEqualTo(expectedIntent);
  }

I get this compile error: Cannot resolve method 'assertThat(android.content.Intent).

The two possibilities I see for importing this method are org.hamcrest.MatcherAssert.assertThat and org.junit.Assert.assertThat, neither of which have a single-argument assertThat method as is being used in this Robolectric test.

My app's build.gradle has these dependencies:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:design:23.1.0'

    testCompile "org.robolectric:robolectric:3.0"
    testCompile 'junit:junit:4.12'
}

What framework/library is this test using?

Aucun commentaire:

Enregistrer un commentaire