dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Automatically post test results in JIRA Adaptavist Tool from rest api test cases run

  1. #1
    Join Date
    Feb 2019
    Posts
    2

    Automatically post test results in JIRA Adaptavist Tool from rest api test cases run

    I am looking for an idea to update my automation test cases in JIRA Adaptavist Test Management Tool. The test cases are written in Java & TestNg and are running on a VM. Please suggest what is a good method to update test results(Pass Or Fail) automatically in JIRA Adaptavist Test Management Tool. Currently, we are manually updating results in the tool.

    Problem with using Zephyr and XRay or any other thrid-party COTS tool is that because of the cumbersome and delayed approval processes.

    I appreciate your time, help and support.

    Our Android test team developed the following code and we don't know how to achieve as they did.

    Here is the android team's code :


    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() 
    }

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,149

    Re: Automatically post test results in JIRA Adaptavist Tool from rest api test cases

    Our Android test team developed the following code
    Why not ask them how it is done?

  3. #3
    Join Date
    Feb 2019
    Posts
    2

    Re: Automatically post test results in JIRA Adaptavist Tool from rest api test cases

    Quote Originally Posted by Arjay View Post
    Why not ask them how it is done?
    Sorry, if it is that easy - I wouldn't post it in forum.

    However, I come to know a way to resolve this by following. And I do not know how to create custom annotation, annotating test method with new annotation and implementing ITestNGListener. Working on them now.

    1. Create a new custom annotation to be used referring Jira ID for a test case.
    2. Annotate @Test method with the new annotation to bind a test method to its JIRA ID.
    3. Now by building a TestNG listener by implementing ITestNGListener and within its onTestFailure() retrieve the Jira ID by retrieving the custom annotation via the ITestResult.getTestMethod().getConstructorOrMethod().getMethod() call, and then fire a RESTful call to your Jira instance to update the test results.

    If you have a sample code of such, will be very helpful for our team.

    Thank you.
    A seeker.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)