我有一个 groovy 脚本,它循环遍历每个测试步骤、每个测试用例、项目中的每个测试套件。项目中的每个测试用例都有两个自定义属性分配给它是,Test_Case_Response_Time
和Test_Case_Response_Size
。我正在尝试获取它,以便当它循环遍历每个测试用例时,它会记录每个测试用例的这两个自定义属性。
常规脚本:
//Loop thru the suites, followed by cases in each suite
suites.each
{ suite ->
//For each test SUITE perform the following action
//------------------------------------------------
def tSuite = project.getTestSuiteByName(suite)
tSuite.testCaseList.each
{ kase ->
//For each test CASE perform the following action
//-----------------------------------------------
kase.testStepList.each
{
//For each test step perform the following action
//-----------------------------------------------
if(it.metaClass.hasProperty(it,'assertionStatus')){
def assertions = it.getAssertionList()
assertions.each
{ assertion ->
if(it.assertionStatus == AssertionStatus.VALID)
{
PassedTestCase += 1
}
else if(it.assertionStatus == AssertionStatus.FAILED)
{
FailedTestCase += 1
}
}
}
//-----------------------------------------------
}
log.info testRunner.testCase["Test_Case_00: Setup"].getPropertyValue("Test_Case_Response_Time")
log.info testRunner.testCase.testSuite.getTestCaseByName("Test_Case_00: Setup").getPropertyValue("Test_Case_Response_Time")
//-----------------------------------------------
}
//-----------------------------------------------
}
我尝试了以下方法但没有成功:
log.info testRunner.testCase[kase.name].getPropertyValue("Test_Case_Response_Time")
log.info testRunner.testCase.testSuite.getTestCaseByName(kase.name).getPropertyValue("Test_Case_Response_Time")
第一行给我以下内容
groovy.lang.MissingPropertyException: 没有这样的属性: Test_Case_00: 类的设置: com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase 第 37 行错误
第二行给了我以下错误:
java.lang.NullPointerException:无法在第 37 行的空对象错误上调用方法 getPropertyValue()
我相信我在寻找错误的测试套件。使用以下我能够让它找到正确的属性:
testRunner.testCase.testSuite.project.getTestSuiteByName(suite).getTestCaseByName(kase.name).getPropertyValue("Test_Case_Response_Time")
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句