2011-12-16 10 views
0

JUnit 4を使用して、Androidのサンプルテストプロジェクトを2-3のJavaファイルのみで提供します。 これを実行しようとしていました。アンドロイドテストプロジェクトのJunit 4ランナー "Sample Project"

私のメインテストファイル。

import org.junit.runner.RunWith; 
import org.junit.runners.Suite; 
@RunWith(Suite.class) 
@Suite.SuiteClasses({ 
SimpleMathTest.class 
// add other classes here (comma separated) 
}) 
public class TestSuite { 
} 

と私は

import org.junit.After; 
import org.junit.AfterClass; 
import org.junit.Before; 
import org.junit.BeforeClass; 
public class SimpleMathTest { 
    @BeforeClass 
    public static void setUpBeforeClass() throws Exception { 
    } 
    @AfterClass 
    public static void tearDownAfterClass() throws Exception { 
    } 
    @Before 
    public void setUp() throws Exception { 
    } 
    @After 
    public void tearDown() throws Exception { 
    } 
} 

でのJUnit 4としてではなく、実行エラーが表示の時に別のテストファイルを作っ:

SampleTest:テストに

の起動に失敗しました

私にいくつかの解決策を教えてください。

ありがとうございました

答えて

0

@Testメソッドはありません。

追加:

@Test 
public void test() { 
    //Test code here 
} 
2

次の手順は、私の仕事:新しいテストランチャーを追加enter image description here

    1. 新しいJUnitの(およびNOT "AndroidのJUnitのテスト")Testconfigurationを作成します。 enter image description here
    2. 次のランチャーを選択してください。enter image description here

    この構成では、単体テストを実行できます。彼らはPCで実行され、電話では実行されません。お役に立てれば。

  • 関連する問題