Mic*_*iyo 8 android unit-testing robolectric
我正在尝试从Robolectric.org的Writing Your First Test页面进行测试.有问题的测试看起来像这样:
@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);
}
Run Code Online (Sandbox Code Playgroud)
我得到这个编译错误:Cannot resolve method 'assertThat(android.content.Intent).
我看到用于导入此方法的两种可能性是,org.hamcrest.MatcherAssert.assertThat并且org.junit.Assert.assertThat,这两种方法都没有assertThat像本Robolectric测试中使用的单参数方法.
我的应用程序build.gradle有这些依赖项:
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'
}
Run Code Online (Sandbox Code Playgroud)
这个测试使用什么框架/库?
Eug*_*nov 18
这既不是junit或hamcrest断言API.我认为它是Android AssertJ或只是AssertJ:
testCompile 'org.assertj:assertj-core:1.7.1'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3572 次 |
| 最近记录: |