2016-05-28 6 views
0

私のアンドロイドスタジオはJUnit 3を実行しています。どうすればJUnit 4に変更できますか? 私のgradleファイルが正しいと思います。アンドロイドスタジオ:junit 3からjunit 4への変更方法

android { 
    … 
    defaultConfig { 
    … 
    testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" 
    } 
    … 
} 

dependencies { 
    // Required -- JUnit 4 framework 
    testCompile 'junit:junit:4.12' 
    // Optional -- Mockito framework 
    testCompile 'org.mockito:mockito-core:1.10.19' 

    androidTestCompile 'com.android.support:support-annotations:23.2.0' 
    androidTestCompile 'com.android.support.test:runner:0.4.1' 
    androidTestCompile 'com.android.support.test:rules:0.4.1' 
    // Optional -- Hamcrest library 
    androidTestCompile 'org.hamcrest:hamcrest-library:1.3' 
    // Optional -- UI testing with Espresso 
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' 
    // Optional -- UI testing with UI Automator 
    androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1' 
} 

私はAndroidのメーカー2.1.1

更新

を使用しています実際には、私はJUnitの4を使用していますが判明したが、何らかの理由で私はtestSomeMethodForXのようtestと私のテストケースの前に付ける必要があり単にsomeMethodForXとは対照的です。 JUnit 4では、この接頭辞はもはや必要ではないと思いましたか?

+0

テストコードを共有できますか? – Mureinik

答えて

1

クラスがまだTestCase(または別のクラスがTestCaseに拡張されている)の場合、JUnit 4ではJUnit 3テストが実行されるため、接頭辞としてtestを付ける必要があります。 TestCaseをもう拡張せず、@Test注釈が存在する場合は実行されます。

+0

私のクラスは 'TestCase'を拡張しません –

+0

テストコードをいくつか用意してください。 –

関連する問題