के लिए सही AssertThat विधि आयात करना मैं Robolectric.org के Writing Your First Test पृष्ठ से परीक्षण चलाने का प्रयास कर रहा हूं। सवाल में परीक्षण इस तरह दिखता है:Robolectric टेस्ट
@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);
}
मैं इस संकलन त्रुटि मिलती है: Cannot resolve method 'assertThat(android.content.Intent)
।
दो संभावनाएं मैं इस विधि आयात करने के लिए देख org.hamcrest.MatcherAssert.assertThat
और org.junit.Assert.assertThat
, जिनमें से न तो के रूप में इस Robolectric परीक्षण में इस्तेमाल किया जा रहा है एक एकल तर्क assertThat
विधि होती है।
मेरे एप्लिकेशन की 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'
}
क्या ढांचे/पुस्तकालय इस परीक्षण का उपयोग कर रहा है?
यह न तो 'junit' या' hamcrest' कथनों है Gradle पहली पंक्ति रखो। मुझे लगता है कि यह 'एंड्रॉइड एसेर्टजे' है या सिर्फ 'AssertJ' –
तो यह था। धन्यवाद! अगर आप एक उत्तर पोस्ट करना चाहते हैं; मैं स्वीकार करूंगा – Michiyo
आप दावे के लिए Google सत्य का भी उपयोग कर सकते हैं: https://github.com/google/truth –