运行 因为 java 应用程序不工作
Run as java application not working
我有一些测试代码,当我尝试 运行 时使用 TESTNG,因为 'Java Application' 我没有看到任何东西。
我没有 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 项目也有同样的问题。有人有什么想法吗?
你绝对需要一个 main 方法来 运行 这个 class,考虑到在不同的 class 中没有创建这个 class 的实例(即使那样,它必须有一个主要方法)。
编辑:我想如果您的目标是 运行 addNotificationMessage1()
方法,您可以创建以下主要方法:
public static void main(String[] args){
addNotificationMessage1();
}
原来我的IDE中没有安装TestNG。
在我的 IDE 上安装 TesNG 后,它现在工作正常。
我有一些测试代码,当我尝试 运行 时使用 TESTNG,因为 'Java Application' 我没有看到任何东西。
我没有 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 项目也有同样的问题。有人有什么想法吗?
你绝对需要一个 main 方法来 运行 这个 class,考虑到在不同的 class 中没有创建这个 class 的实例(即使那样,它必须有一个主要方法)。
编辑:我想如果您的目标是 运行 addNotificationMessage1()
方法,您可以创建以下主要方法:
public static void main(String[] args){
addNotificationMessage1();
}
原来我的IDE中没有安装TestNG。
在我的 IDE 上安装 TesNG 后,它现在工作正常。