私はjunitテストで新しくなりました。私はどこが間違っているのか分かりません。ここでは(私の本当のテストを簡素化)の簡単なユニットテストです:assertEquals - 常にテストに合格 - Androidスタジオ
import android.test.InstrumentationTestCase;
public class exampleTest extends InstrumentationTestCase {
String ob1, ob2;
public void setUp() throws Exception {
super.setUp();
ob1 = "hi";
ob2 = "bye";
}
public void testEx()throws Exception{
assertEquals("Error", ob1, ob2);
}
}
私はテストが常に合格することを得るexampleTest私が実行したとき。
どこが間違っていますか?誰かが私を説明できますか?問題のアプリケーションは、複雑で長いと古いですので
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:21'
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.myapp.mobile.app.servizi.activity"
minSdkVersion 9
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src/test/java']
}
}
//instruct the Gradle build system to return default values for method calls
//in the `android.jar`with the following configuration in your Gradle build file.
testOptions {
unitTests{
returnDefaultValues = true
}
}
}
dependencies {
compile project(':androidswitchbackport')
compile project(':librarySlidingMenu')
compile project(':libraryViewPagerIndicator')
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.android.gms:play-services:7.0.0'
compile 'com.actionbarsherlock:actionbarsherlock:[email protected]'
compile 'com.android.support:support-v4:21.0.0'
//dependency for Local test
// Required -- JUnit 4 framework
testCompile 'junit:junit:4.12'
// Optional -- Mockito framework
testCompile 'org.mockito:mockito-core:1.10.19'
}
Gradleのファイルは、多くの依存関係を持っている、と私はテストをする責任があります。
私のbuild.gradleファイルがあります。あなたが私に手を差し伸べれば、私は感謝しています。
あなたはそれが –
、それは動作しますが動作させるために@Testを使ってテストメソッドに注釈を付けることがありますか? –
ありがとう@JuanCruzSoler!しかし、テストメソッドに '@Test'を挿入すると、それに対応して 'import org.junit.Test;'がインポートされます。私はこのエラーがあります: 'エラー:パッケージorg.junitは存在しません' AND 'エラー:シンボルクラスを見つけることができませんテスト'何をすべきですか? (申し訳ありませんが、私はテストで新しいです) – Seva