[英]How to run testcase and testsuite using Groovy in soapui?
i have some projects in soapui. 我在soapui有一些项目。 i want to execute testsuites and testcases of these projects.
我想执行这些项目的测试套件和测试用例。 i tried with this groovy code:
我试过这个groovy代码:
//get test case from other project or from the same one
project = testRunner.getTestCase().getTestSuite().getProject().getWorkspace().getProjectByName("Project1")
testSuite = project.getTestSuiteByName("TestSuite 1 - Login");
testCase = testSuite.getTestCaseByName("TestCase 1-Login");
Thread.sleep(3000)
testSuite2 = project.getTestSuiteByName("TestSuite3 - Report");
testCase2 = testSuite.getTestCaseByName("TestCase1 - Report");
// run test case
runner = testCase.run(new com.eviware.soapui.support.types.StringToObjectMap(), false);
Thread.sleep(3000)
runner2 = testCase2.run(new com.eviware.soapui.support.types.StringToObjectMap(), false);
When i run this groovy code, i have the following error message: java.lang.NullPointer.Exception cannot invoke method run() on null object for the last line 当我运行这个groovy代码时,我有以下错误消息:java.lang.NullPointer.Exception无法调用最后一行的null对象上的方法run()
runner2 = testCase2.run(new com.eviware.soapui.support.types.StringToObjectMap(), false);
If i remove the last line it's working well. 如果我删除最后一行它运行良好。
Any help please. 请帮忙。 Thank you
谢谢
I know this is super late to answer this question, but i will answer this so that it can help help seeking for help. 我知道回答这个问题已经很晚了,但我会回答这个问题,以便它可以帮助寻求帮助。
instead of Thread.sleep(3000), just use: 而不是Thread.sleep(3000),只需使用:
runner.waitUntilFinished()
Now it will wait until execution of step 1 get finished. 现在它将等到步骤1的执行完成。 Then it will start executing Step 2.
然后它将开始执行第2步。
我唯一能想到的是你在step2上调用了错误的测试用例,我对其他测试用例进行了相同的测试,并且它发生了同样的事情如果我为我要执行的测试用例添加了错误的名称。
// TO RUN A TEST SUITEs ALL get APIs, getting testSuite handle from current //test_Case
// TO POST COMMENT I HAVE ADDED underscore char BELOW
// u need to import here
def my_TestSuite = testRunner.testCase.testSuite
log.info(my_TestSuite.name)
for (my_TestCase in my_TestSuite.get_TestCaseList())
{
for (testStep in myTestCase.get_TestStepList())
{
if( testStep instanceof WsdlTestRequestStep || testStep instanceof RestTestRequestStep ) {
def http_Verb = (testStep.getTestRequest().getMethod())
String apiType = http_Verb.toString()
if (apiType == "GET"){
log.info(myTestCase.name)
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.