2015-10-16 82 views
-5

我有一些測試代碼,當我嘗試以'Java應用程序'運行時使用TESTNG我什麼也沒看到。我沒有public static void main(String[] args),因爲TestNG不會提示它。作爲Java應用程序運行不起作用

import java.util.*; 
import org.testng.annotations.Test; 
import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.htmlunit.HtmlUnitDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 

public class Testing 
{ 
    @Test 
    public void addNotificationMessage1(){ 
    { 
     WebDriver driver = new FirefoxDriver(); 
     driver.get("http://www.google.com"); 

    } 
} 

該項目以前在我的舊電腦上工作,但沒有更多。我使用的更新的TestNG項目也有同樣的問題。有沒有人有沒有想法?

+0

http://stackoverflow.com/help/mcve –

回答

0

你絕對需要一個主要的方法來運行這個類,考慮在這個類中沒有創建這個類的實例(即使這樣,它也必須有一個主方法)。

編輯:我想如果你的目標是運行addNotificationMessage1()方法,您可以創建以下主要方法:

public static void main(String[] args){ 
    addNotificationMessage1(); 
} 
+1

我認爲在這種情況下,我們需要聲明'addNotificationMessage1();'作爲'static'方法。 – AGill

1

原來TestNG的不是安裝在我的IDE。

一旦我在我的IDE上安裝TesNG,它現在工作正常。

相關問題