[英]Run as java application not working
当我尝试作为“Java 应用程序”运行时,我有一些使用 TESTNG 的测试代码,但我什么也没看到。
我没有public static 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 项目也有同样的问题。 有人有什么想法吗?
原来我的IDE中没有安装TestNG。
在我的 IDE 上安装 TesNG 后,它现在可以正常工作了。
你绝对需要一个 main 方法来运行这个类,考虑到没有在不同的类中创建这个类的实例(即使这样,它也必须有一个 main 方法)。
编辑:我想如果您的目标是运行addNotificationMessage1()
方法,您可以创建以下主要方法:
public static void main(String[] args){
addNotificationMessage1();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.