Pra*_*gre 4 java testng selenium
我是 testNG 的新手,我有以下代码:
@BeforeMethod
public void getGroup(ITestAnnotation annotation){
System.out.println("Group Name is --" + annotation.getGroups()) ;
}
@Test(groups = { "MobilSite" })
public void test1(){
System.out.println("I am Running Mobile Site Test");
}
Run Code Online (Sandbox Code Playgroud)
我想要 before 方法中的组名,我尝试使用 ITestAnnotation但是当我运行测试时我收到以下错误
Method getGroup requires 1 parameters but 0 were supplied in the @Configuration annotation.
Run Code Online (Sandbox Code Playgroud)
你能帮助我应该从 XML 传递的参数吗?
使用反射方法获取测试组如下:
@BeforeMethod
public void befMet(Method m){
Test t = m.getAnnotation(Test.class);
System.out.println(t.groups()[0]);//or however you want to use it.
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5313 次 |
| 最近记录: |