首页 > 解决方案 > 自动在 JIRA Adaptavist 工具中发布测试结果,来自 Eclipse 上运行的 rest api 测试用例

问题描述

我正在寻找在 JIRA Adaptavist 测试管理工具中更新我的自动化测试用例的想法。测试用例是用 Java 和 TestNg 编写的,并在 VM 上运行。请建议在 JIRA Adaptavist 测试管理工具中自动更新测试结果(通过或失败)的好方法。目前,我们正在手动更新工具中的结果。

使用 Zephyr 和 XRay 或任何其他第三方 COTS 工具的问题在于繁琐且延迟的审批流程。

感谢您的时间、帮助和支持。

我们的 Android 测试团队开发了以下代码,我们不知道如何实现。

Here is the android team's code :

Open class rTestCaseHelper {

@rule
@JvmField
val grantWriteStorageAccess: GrantPermissionRule = GrantPermissionRule.grant(
android.Manifest.permission.WRITE_EXTERNAL_STORAGE)

@rule
@JvmField
val reportRule :TestWatcher = Object : TestWatcher() {
var startTime = 0
override fun starting(description: Description?) {
startTime = System.currentTimeMillis().toInt()

if (sharedPreference.getTestCount() == 0) {
testManager.getTestIdAndStoreToSharedPreference()
testManager.createTestCycle()
}

}

override fun succeeded(description: Description?) {
if(description != null) {
val executionTime = System.currentTimeMillis().toInt() - startTime
testManager.generateExecutionReport(description.methodName, result: "Pass", executionTime)

}

}

override fun failed(e: Throwable?, description: Description?) {
super.failed(e.description)
if(description != null) {
val executionTime = System.currentTimeMillis().toInt() - startTime
testManager.generateExecutionReport(description.methodName, result: "Fail", executionTime, e)

}

}

override fun finished(description: Description?) {
sharedPreference.setTestCount(sharedPreference.getTestCount() -1)
//Post artfact report link to test cycle (TODO)
testManager.postWebLinkToTestCycle()

rSharedPreference.preference.edit().clear()
Log.d(tag: "QAA", msg: "Automation suite finished and sharedPreference data is cleared!")

}

}

}
fun initializeSDK(activeProtection: Boolean = false): Boolean {
rSdkEnvironment.initializeSDK(activeProtection, InstrumentationRegistry.getInstrumentation().targetContext)
return rSdk.isInitialized() 
}

标签: javatestngjira

解决方案


不确定您到底在寻找什么。这是执行此操作的一种方法:创建一个新的自定义注释,可用于引用代表特定测试用例的 Jira ID。使用新注解对 @Test 方法进行注解,以便我们将测试方法绑定到其 JIRA ID。现在通过实现 ITestNGListener 构建一个 TestNG 侦听器,并在其 onTestFailure() 中通过 ITestResult.getTestMethod().getConstructorOrMethod().getMethod() 调用检索自定义注释来检索 Jira ID,然后对您的 Jira 实例进行 RESTful 调用更新测试结果。“生活中所有美好的事物要么是非法的、昂贵的、肥胖的,要么是爱上别人的!”

testManager.postWebLinkToTestCycle()

rSharedPreference.preference.edit().clear()
Log.d(tag: "QAA", msg: "Automation suite finished and sharedPreference data is cleared!")

}

}

}
fun initializeSDK(activeProtection: Boolean = false): Boolean {
rSdkEnvironment.initializeSDK(activeProtection, InstrumentationRegistry.getInstrumentation().targetContext)
return rSdk.isInitialized() 
}

推荐阅读