如何将 SoapUI 的结果添加到 Jira?

How can I add the results from SoapUI to Jira?

我正在 SoapUI 中自动化一些测试用例,我必须在 Jira 中添加自动化测试的结果。我该怎么做?
将在 Jira 中创建一个测试用例,我需要将该特定测试用例映射到我在 SoapUI 中自动化的测试用例,并在测试完成后添加结果 executed.I 只需要查看结果 Pass/Failed 在 Jira 测试用例中。
谢谢

以下是我在这种情况下会想到的方法。

让我们假设 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
为了实现这一目标,没有简单的方法。使用以下任一方式:

  1. 写一些代码(用你喜欢的语言)来调用 JIRA REST API to add a comment to the issue. wslite 是我更喜欢的非常好的简单库。

  2. 使用soapui测试用例:

    • 添加一个 rest 方法,以便能够在 jira 中对项目进行评论。或者完全在一个单独的项目中,因为它与实际测试无关。见 here
    • 创建一个虚拟测试用例,并使用此方法添加一个测试步骤。这个测试用例可以在同一个测试套件中,也可以在项目的其他地方。
    • 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.
}