2017-10-16 8 views
0

TestNGがテストを実行していない理由は何ですか? これはクラスコード(Java)のである:TestNGがエクリプスでテストを実行していない

public class main { 
@Test 
public static void main(String[] args) throws AWTException, InterruptedException 

これは、日食のパスです: enter image description here

、これはXMLファイルです:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> 
<suite name="Suite"> 
    <test name="Test"> 
    <classes> 
     <class name="test.main"/> 
    </classes> 
    </test> <!-- Test --> 
</suite> <!-- Suite --> 
+0

あなたのテストコードには 'main()'メソッドは必要ありません。TestNGをバイパスしようとすると、TestNGが完全にバイパスされていると思います。 – jsheeran

+0

私は '@ Test'メソッドが引数を持つことができないのですか?とにかく、テストメソッドが実行されるとき、どこから 'args'の値が得られますか?追加されたもの:可能ですが、http://testng.org/doc/documentation-main.html#test-methods(5.6参照)のルールに従っていない可能性があります。 – SantiBailors

+0

文字列配列の引数をmainメソッドから削除し、試してください。それは動作するかもしれません – Murthi

答えて

1

私はあなたのtestngのデモテンプレートをここに掲示しました。あなたはクラスとデフラのwebdriverを取る必要があります。 @BeforeMethodが起動する前に実行されます@Test次に@AfterMethodあなたが手伝ってくれることを願っています。

package stackoverflow; 
    import org.openqa.selenium.WebDriver; 
    import org.openqa.selenium.chrome.ChromeDriver; 
    import org.testng.annotations.*; 

    public class DemoTestNGClass { 
     public static WebDriver driver; 
     @BeforeMethod 
     public void setUp1() throws Exception { 

      driver= new ChromeDriver(); 


     } 
     @Test 
     public void Homepage() throws InterruptedException { 
    //Your operation 
     } 

     @Test 
     public void ListingPage() throws InterruptedException { 

    //Your operation 
     } 

     @AfterMethod 
     public void afterresult(){ 
      driver.close(); 
     } 

    } 
0
  1. チェックEclipseプラグインかどうかTestNGがあなたのマシン上に存在します。
  2. Help => Eclipse Marketplaceから最新のものをインストールしない場合。
  3. Eclipseを再起動します。
関連する問題