Ask a Question

Junit5 + Zephyr Scale + Gradle project integration

AlexGnu
Occasional Visitor

Junit5 + Zephyr Scale + Gradle project integration

Hey,

My project: Gradle 7.6. + Java 11 + JUnit 5.9.2 + Selenium. Our UI test are run using Jenkins.
Goal: To send tests results to Zephyr Scale (integrated to our corporate Jira)


1) First of all, I tried to follow this instruction (https://github.com/SmartBear/zephyr-scale-junit-example) >  I am getting the following error: 

{"errorCode":400,"message":"Couldn't find any mapped test cases","status":"Bad Request"}

 while the build is Successful, which mean that test results are created. Each test use recommended by you naming approach (key + testCaseName), for example: 

OR_T48_createNewProduct

As this did not work for me, I tried the 2nd approach (to generate JSON, instead of xml) :
2) Therefore, I decided to follow another your instruction (https://support.smartbear.com/zephyr-scale-server/docs/test-automation/integrations/junit.html?_ga=2...)

Few questions here:
 2.1. How to register Zephyr Scale JUnit Listener in Gradle project?  Because, you showed only Maven example.
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.0</version>
            <configuration>
                <properties>
                    <property>
                        <name>listener</name>
                        <value>com.adaptavist.tm4j.junit.ExecutionListener</value>
                    </property>
                </properties>
            </configuration>
        </plugin>
    </plugins>
</build>


2.2. What is the expected location of test_result.json files in Gradle project?

Really need your help, thanks!

1 REPLY 1
erutan
Occasional Contributor

Hi @AlexGnu 

As per this Open issue: https://github.com/gradle/gradle/issues/1330 Gradle does not support JUnit listeners, so you cannot use this method with gradle.

However in my project I was able to workaround that, using the created JUnit XML reports during build, and upload them to Zephyr using the JUnit XML API in an <Exec> type gradle task to run a command line running a py script.

 

This py script uploads multiple XML files to Zephyr, editing them so that when the test cases are automatically created (if they don't exist) their name will include just the test method name, without the full package and class names, making it more readable in Zephyr.

Just change the script locally to point to the right xml files folder.

The script can be found here: https://gist.github.com/yyahav/c5f7791bd3bb9ec9148ebbdf9aeb5914/raw/57547823a565b45cf7a137e5531cabb0... 

You probably already have an API token, if not you need to create one. Create here: https://support.smartbear.com/zephyr-scale-cloud/docs/rest-api/generating-api-access-tokens.html The token should be passed as a '--token <tokenId>' to the script.

cancel
Showing results for 
Search instead for 
Did you mean: