作为java应用程序运行不工作

作为java应用程序运行不工作,java,webdriver,testng,Java,Webdriver,Testng,我有一些测试代码,当我试图以“Java应用程序”的形式运行时,它使用TESTNG,但我什么也看不到 我没有公共静态void main(String[]args),因为TestNG不会提示它 import java.util.*; import org.testng.annotations.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.Web

我有一些测试代码,当我试图以“Java应用程序”的形式运行时,它使用TESTNG,但我什么也看不到

我没有
公共静态void main(String[]args)
,因为TestNG不会提示它

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项目也有同样的问题。有人有什么想法吗?

您绝对需要一个main方法来运行这个类,考虑到在不同的类中没有创建这个类的实例(即使这样,它也必须有一个main方法)

编辑:我想如果您的目标是运行
addNotificationMessage1()
方法,那么您可以创建以下主要方法:

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

事实证明TestNG并没有安装在我的IDE中


一旦我在IDE上安装了TENG,它现在就可以正常工作了。

我认为在这种情况下,我们需要声明
addNotificationMessage1()作为一种
静态
方法。