SoapUI:是否有单独的测试套件运行 GroovyScript TestStep 检查其他测试套件中的所有其他测试用例?
SoapUI: Have a separate Test Suite that runs a GroovyScript TestStep that checks all other Test Cases In other Test Suites?
我有一个 Groovy 脚本,它读取当前测试用例中已 运行 的测试步骤的断言验证和错误消息。
我目前有 4 个测试套件,有 8 个测试用例,全部有大约 400 个测试步骤。
是否可以有一个单独的测试套件,其中包含一个测试用例和一个包含 groovy 脚本的测试步骤?
此测试套件的唯一目的是 运行 groovy 测试步骤读取所有其他测试套件和测试用例、测试步骤并记录失败的测试步骤。
import com.eviware.soapui.model.testsuite.Assertable.AssertionStatus
def TestSuite = testRunner.getTestCase()
def StepList = TestSuite.getTestStepList()
Failed = 0
Total = 0
log.info "_____Start of Log_____"
// psuedo code
// SuiteList.each
// CaseList.each
StepList.each
{
if(it.metaClass.hasProperty(it,'assertionStatus')){
Total = Total + 1
def assertions = it.getAssertionList()
assertions.each
{ assertion ->
if(it.assertionStatus == AssertionStatus.FAILED)
{
assertion.getErrors().each
{ error ->
log.error "${it.name}: [FAILED] ${error.getMessage()}"
}
Failed = Failed + 1
}
}
}
}
log.info " Script Run: " + Total
log.info " Scripts Failed: " + Failed
log.info "_____End of Log_____"
目前我的输出是:
Tue Oct 25 12:55:20 BST 2016:ERROR:TestStep_0299: [FAILED] Expected Result: 49.401 or 52.002 or 54.602 Actual Result: 41.60164055168. Expression: node.toString().matches((49.401|52.002|54.602)\d*)
Tue Oct 25 12:55:20 BST 2016:ERROR:TestStep_0300: [FAILED] Expected Result: 61.752 or 65.002 or 68.252 Actual Result: 52.0020506896. Expression: node.toString().matches((61.752|65.002|68.252)\d*)
Tue Oct 25 12:55:20 BST 2016:INFO: Script Run: 300
Tue Oct 25 12:55:20 BST 2016:INFO: Scripts Failed: 205
Tue Oct 25 12:55:20 BST 2016:INFO:_____End of Log_____
是否可以 运行 对所有测试套件和测试用例进行此操作。所以我有所有测试步骤的一大日志。
在 SoapUI 中这可能吗?
这是 Groovy Script
循环遍历除当前套件之外的所有套件,因为在您的情况下不需要它。
请关注在线评论。
/**
* This script gets all the suites and
* removes current suite name from total list
* and loopes thru the test cases of each suite
**/
//Get the project object
def project = context.testCase.testSuite.project
//Get the current suite name
def currentSuite = context.testCase.testSuite.name
//Get the suites to process (except the current suite)
def suites = project.testSuiteList.findAll {it}*.name - currentSuite
//Loop thru the suites, followed by cases in each suite
suites.each { suite ->
def tSuite = project.getTestSuiteByName(suite)
tSuite.testCaseList.each { kase ->
kase.testStepList.each {
//Have your code here
}
}
}
我有一个 Groovy 脚本,它读取当前测试用例中已 运行 的测试步骤的断言验证和错误消息。
我目前有 4 个测试套件,有 8 个测试用例,全部有大约 400 个测试步骤。
是否可以有一个单独的测试套件,其中包含一个测试用例和一个包含 groovy 脚本的测试步骤?
此测试套件的唯一目的是 运行 groovy 测试步骤读取所有其他测试套件和测试用例、测试步骤并记录失败的测试步骤。
import com.eviware.soapui.model.testsuite.Assertable.AssertionStatus
def TestSuite = testRunner.getTestCase()
def StepList = TestSuite.getTestStepList()
Failed = 0
Total = 0
log.info "_____Start of Log_____"
// psuedo code
// SuiteList.each
// CaseList.each
StepList.each
{
if(it.metaClass.hasProperty(it,'assertionStatus')){
Total = Total + 1
def assertions = it.getAssertionList()
assertions.each
{ assertion ->
if(it.assertionStatus == AssertionStatus.FAILED)
{
assertion.getErrors().each
{ error ->
log.error "${it.name}: [FAILED] ${error.getMessage()}"
}
Failed = Failed + 1
}
}
}
}
log.info " Script Run: " + Total
log.info " Scripts Failed: " + Failed
log.info "_____End of Log_____"
目前我的输出是:
Tue Oct 25 12:55:20 BST 2016:ERROR:TestStep_0299: [FAILED] Expected Result: 49.401 or 52.002 or 54.602 Actual Result: 41.60164055168. Expression: node.toString().matches((49.401|52.002|54.602)\d*)
Tue Oct 25 12:55:20 BST 2016:ERROR:TestStep_0300: [FAILED] Expected Result: 61.752 or 65.002 or 68.252 Actual Result: 52.0020506896. Expression: node.toString().matches((61.752|65.002|68.252)\d*)
Tue Oct 25 12:55:20 BST 2016:INFO: Script Run: 300
Tue Oct 25 12:55:20 BST 2016:INFO: Scripts Failed: 205
Tue Oct 25 12:55:20 BST 2016:INFO:_____End of Log_____
是否可以 运行 对所有测试套件和测试用例进行此操作。所以我有所有测试步骤的一大日志。
在 SoapUI 中这可能吗?
这是 Groovy Script
循环遍历除当前套件之外的所有套件,因为在您的情况下不需要它。
请关注在线评论。
/**
* This script gets all the suites and
* removes current suite name from total list
* and loopes thru the test cases of each suite
**/
//Get the project object
def project = context.testCase.testSuite.project
//Get the current suite name
def currentSuite = context.testCase.testSuite.name
//Get the suites to process (except the current suite)
def suites = project.testSuiteList.findAll {it}*.name - currentSuite
//Loop thru the suites, followed by cases in each suite
suites.each { suite ->
def tSuite = project.getTestSuiteByName(suite)
tSuite.testCaseList.each { kase ->
kase.testStepList.each {
//Have your code here
}
}
}