Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在使用TestNG时,如果我们定义WebDriver;那么,在不创建该类的对象的情况下,我们如何能够在方法下使用驱动程序呢?_Java_Unit Testing_Testing_Automated Tests_Integration Testing - Fatal编程技术网

Java 在使用TestNG时,如果我们定义WebDriver;那么,在不创建该类的对象的情况下,我们如何能够在方法下使用驱动程序呢?

Java 在使用TestNG时,如果我们定义WebDriver;那么,在不创建该类的对象的情况下,我们如何能够在方法下使用驱动程序呢?,java,unit-testing,testing,automated-tests,integration-testing,Java,Unit Testing,Testing,Automated Tests,Integration Testing,代码运行良好,但为什么?在不创建类对象的情况下Testing123我们如何能够访问该驱动程序 public class Testing123 { WebDriver driver ; @Test public void test1() { driver = new ChromeDriver(); driver.get("http://google.com"); } } TestNG框架负责在幕后创建测试类的实例。基本上,通过使用

代码运行良好,但为什么?在不创建类对象的情况下
Testing123
我们如何能够访问该驱动程序

public class Testing123 {
    WebDriver driver ;

    @Test
    public void test1() {
        driver = new ChromeDriver();
        driver.get("http://google.com");
    }
}

TestNG框架负责在幕后创建测试类的实例。基本上,通过使用'@Test'注释您的方法,注释处理器将类与测试运行程序相关联。有关更多信息,请参阅: