我在SoapUI中自动化一些测试用例,我必须在Jira中添加自动化测试的结果。我怎么能这样做?
将在Jira中创建一个测试用例,我需要将该特定测试用例映射到我在SoapUI中自动化的测试用例,并在测试执行后添加结果。我只需要在Jira中看到结果通过/失败测试用例。
谢谢
答案 0 :(得分:0)
以下是我在这种情况下会想到的方法。
我们假设soapui project
中有一个测试套件。
Jira Issue Id
应作为自定义属性添加到每个测试用例中,例如JIRA_ID
。
可以使用以下TearDown Script
测试套件访问测试用例结果。 Below script只记录详细信息。
for ( testCaseResult in runner.results )
{
testCaseName = testCaseResult.getTestCase().name
log.info testCaseName
if ( testCaseResult.getStatus().toString() == 'FAILED' )
{
log.info "$testCaseName has failed"
for ( testStepResult in testCaseResult.getResults() )
{
testStepResult.messages.each() { msg -> log.info msg }
}
}
}
但是,在您的情况下,应分别为每个测试用例的jira issue id
添加注释
为了实现这一点,不是一个简单的方法。使用以下任一方式:
编写一些代码(使用您的首选语言)来调用JIRA REST API来为问题添加评论。 wslite是我更喜欢的非常好的简单库。
使用soapui测试用例:
do not forget
到禁用此测试用例,因为这不是您的实际功能测试用例。 jira
以下是稍加修改的测试套件TearDown Script
,以满足您的要求。但是,您需要使用上述方法之一实现callJiraRestAPI
方法。
for ( testCaseResult in runner.results ) {
testCaseName = testCaseResult.getTestCase().name
def jiraId = testCaseResult.getTestCase().getPropertyValue('JIRA_ID')
log.info testCaseName
def message = new StringBuffer()
if ( testCaseResult.getStatus().toString() == 'FAILED' ) {
log.info "$testCaseName has failed"
message.append("$testCaseName has failed")
for ( testStepResult in testCaseResult.getResults() ) {
testStepResult.messages.each() { msg ->
log.info msg
message.append(msg)
}
}
} else {
log.info "$testCaseName has passed"
message.append("$testCaseName has passed")
}
//calling jira rest api to add the comment
callJiraRestAPI(jiraId, testCaseResult.getTestCase(), message.toString())
}
//You need to Implement calling jira rest api to add the comment
def callJiraRestAPI(jiraId, testKase, message) {
//write your code using either 1 or 2 way
//of course, REST request needs to be set with message
//and jiraId is needed and testKase is useful if you choose to use 2nd way, otherwise not needed.
}