使用Java进行TestNG

5 testng

在使用TestNG和Java时,我收到以下错误:'类型不匹配:无法将测试转换为注释'

注意:使用eclipse IDE.构建路径包含TestNG jar还安装了用于eclipse IDE的TestNG插件.

你能告诉我为什么我得到上述错误吗?

谢谢

码:

import org.testng.annotations.*;
public class ChangeResolutionOnMainWatch {

    @BeforeTest

    public void startTest() throws Exception {
        watch.startSelenium();
        stream_delay=Integer.parseInt(System.getProperty("stream_delay").trim());
    }

    @Test 

    public void launchFalcon()throws Exception{

        watch.deleteAllCookie();
        watch.launchFalcon();
    }
}          
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,'@Test'表示法给出了错误

小智 4

虽然导入 org.testng.annotations.*; 进口一切,它不起作用。但是当我只导入所需的类时,它工作得很好。

前:

import org.testng.annotations.*;  
Run Code Online (Sandbox Code Playgroud)

哪个不起作用

后:

import org.testng.annotations.BeforeTest;   
import org.testng.annotations.Test;   
import org.testng.annotations.AfterTest;
Run Code Online (Sandbox Code Playgroud)

哪个有效