2012-04-10 6 views
3

このテストケースを正常に動作させるには問題があります。誰かが私を正しい方向に向けることができますか?私は何かが間違っていることを知っている、私はちょうど何を知らない。junit.framework.AssertionFailedError:レジスタ内のテストが見つかりません

import org.junit.*; 
import com.thoughtworks.selenium.*; 
import org.openqa.selenium.server.*; 

@SuppressWarnings("deprecation") 

public class register extends SeleneseTestCase { 

    Selenium selenium; 
    private SeleniumServer seleniumServer; 
    public static final String MAX_WAIT = "60000"; 
    public final String CRN = "12761"; 

    public void setUp() throws Exception { 
    RemoteControlConfiguration rc = new RemoteControlConfiguration(); 
    rc.setAvoidProxy(true); 
    rc.setSingleWindow(true); 
    rc.setReuseBrowserSessions(true); 

    seleniumServer = new SeleniumServer(rc); 
    selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://google.com/"); 
    seleniumServer.start(); 
    selenium.start(); 
    } 

    @Test 
    public void register_test() throws Exception { 
    //TESTS IN HERE 
    } 

    @After 
    public void tearDown() throws Exception { 
    selenium.stop(); 
    // Thread.sleep(500000); 
    } 
} 

そして、私は次のエラーを取得しています:

junit.framework.AssertionFailedError: No tests found in register 
at jumnit.framework.TestSuite$1.runTest(TestSuite.java:97) 

私は困惑します。

答えて

24

TestCase(またはSeleniumTestCase)を拡張することも、JUnit注釈(@Test)を使用することもできません。 JUnit3と4のテストランナーは異なります.JUnitはTestCaseを拡張したと判断して、古いランナーを使用します。

@Testアノテーションを削除して、代わりに "test"という単語をプレフィックスとして使用してテストを命名する古い規則に従って、修正します。

public void testRegister() throws Exception { 
    //TESTS IN HERE 
} 

PS。私はラクダのケーシングのような、より標準的なJava命名規則に従うことをお勧めします。

PPS。これについて詳しく説明するlinkがあります。

1

このエラーは、私のケースでは、つまり、<junit> Antタスクでテストを実行していましたが、1.7以降のバージョンのAntを参照することで解決できました。 Ant 1.7+の栄誉は<classpath>の要素を入れ子にしました.JUnit 4.x jarを指していましたが、これはCodeSpelunkerが示したように@Testアノテーションを理解しています。 http://ant.apache.org/faq.html#delegating-classloaderは私のためにahaの瞬間を提供した。

2

これは、現在実行中のテストケースクラスのテストで始まるメソッド名を作成しなかったことを意味します。

関連する問題