我感到很傻,我知道我做错了事,但我不知道。我是新来的testng。我不断收到以下代码出现错误No tests found for given includes: [tests.OTP.get
]
class OTP{
public static Logger log = LogManager.getLogger(HomePage.class.getName())
String environment = 'qatesting'
String number = '0769878787'
@Test
def get(){
// SoapuiOTP s = new SoapuiOTP(environment,number)
// s.getOTP()
log.info("hello")
Assert.assertEquals(0,System.getProperty("SOAPUI_OTP"))
log.info System.getProperty('SOAPUI_OTP')
}
}
我正在使用def get()
旁边的播放按钮(intelij)进行测试,但在课堂上却遇到了相同的错误。请协助,我已尝试使我的缓存无效并重新启动。我看了TestNG No tests found. Nothing was runTestNG - no tests were found无济于事
您需要在用def
注释的方法中用void
替换@Test
。如文档所述:
测试方法用
@Test
注释。除非您在testng.xml中将@Test
设置为true,否则将忽略带有allow-return-values
注释的方法并返回一个值:<test allow-return-values="true">
来源:https://testng.org/doc/documentation-main.html#test-methods
def
返回类型将编译为Object
,而不是void
,因此默认情况下,Test NG忽略此方法,假定它返回了值。