我註解班裏喜歡這裏AndroidJUnit4測試沒有發現
@RunWith(AndroidJUnit4.class)
public class WorkdayProviderTest
Futhermore,也註釋這樣
@Test
public void insert_dataInsertsCorrectly()
我的測試方法。最後,配置了我的build.gradle defaultConfig和依賴這樣
defaultConfig {
applicationId 'com.jueggs.workinghours'
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
androidTestCompile "junit:junit:4.12"
androidTestCompile "com.android.support:support-annotations:23.3.0"
androidTestCompile "com.android.support.test:runner:0.4.1"
androidTestCompile "com.android.support.test:rules:0.4.1"
androidTestCompile "com.android.support.test.espresso:espresso-core:2.2.1"
androidTestCompile "com.android.support.test.espresso:espresso-contrib:2.2.1"
androidTestCompile "org.hamcrest:hamcrest-library:1.3"
並配置了這樣的測試運行
和it's告訴我
No tests were found
Test running failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'
如何解決這個問題?
是我有這個依賴關係,查看更新 – Lemao1981
刪除'@RunWith(AndroidJUnit4.class)'並運行test。你也可以用'@RunWith(JUnit4.class)'改變'@RunWith(AndroidJUnit4.class)',它應該運行。 – piotrek1543
沒有解決問題,在兩種情況下都找不到任何測試。在0.4.1版本中,類AndroidJUnit4存在 – Lemao1981