【发布时间】:2015-07-18 06:53:12
【问题描述】:
我想对来自不同类的测试使用相同的 @BeforeMethod 实例,但它不起作用
package com.code.theCode
public class theConfiguration{
@BeforeMethod(groups = {"example"}, alwaysRun = true)
public void setupMethod(){
System.out.println("inside setupMethod");
}
}
/////////////////////////////////////// ///////////////////////////////////////// ///////////////////////////////////////// ////////////
package com.code.test
public class theTest{
@Test(groups = {"example"}, alwaysRun = true)
public void setupMethod(){
System.out.println("inside test");
}
}
testng.xml
<suite name="AllTests" verbose="1">
<test name="AllTests">
<groups>
<run>
<include name="example">
</run>
</groups>
<packages>
<package name="com.code.*" />
</packages>
</test>
运行我的测试时,我得到空白的系统输出
非常感谢任何帮助
【问题讨论】:
-
如何执行?
-
如果你得到空白的系统输出,那么你的
BeforeMethod以及你的测试没有被执行,所以问题不仅仅是BeforeMethod。你是如何运行测试的? IDE?安慰?有哪些论据? -
是的,通过并打印 System.out.println("inside test");但不会打印@BeforeTest syso ...它不会在日志中显示错误:(
-
你是如何运行测试的? IDE?安慰?有哪些论据?
-
Eclipse IDE,TestNG 运行配置指向 testng.xml 套件文件