Import Results using Maven Plugin for Cucumber

If the automation project includes a Cucumber + Java (with Maven) structure, then configure the Maven dependency in the project as described below.

Working Sample

Refer to Sample Projects for Automation section for a more concrete end-to-end example.

Open the pom.xml and add the configurations as described on the Automation API screen for Maven.

1. Use API Key for Importing Results

Please Generate API Key if you do not have an API key for the selected project.

2. Import Results

Step 1: Add the following to the <build> > <plugins> block in your pom.xml:

<build>
       <plugins>
          <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-surefire-plugin</artifactId>
             <version>2.22.0</version>
          </plugin>
          <plugin>
             <groupId>com.qmetry</groupId>
             <artifactId>automation</artifactId>
             <version>2.0.11</version>
             <executions>
                <execution>
                   <phase>test</phase>
                   <goals>
                      <goal>CucumberFileUpload</goal>
                   </goals>
                </execution>
             </executions>
          </plugin>
       </plugins>
    </build>

Refer to the View Import Results using the REST API section for a list of all possible request parameters.

Step 2: Add the following to the <pluginRepositories> block in pom.xml, like:

<pluginRepositories>
      <pluginRepository>
           <id>qmetrytestmanager-mvn-repo</id>
            <name>QMetry Test Manager Maven Repository</name>
            <url>https://raw.github.com/qmetry/qtm4j-maven-uploader/mvn-repo/</url>
            <releases>
                   <enabled>true</enabled>
                   <updatePolicy>always</updatePolicy>
            </releases>
       </pluginRepository>
</pluginRepositories>

Step 3: Add the qmetry.properties file to the root directory of your project. Download the sample file.

Configure the properties:

Authorization: (automation.qmetry.authorization)

The restrictions provided by Jira protect Maven automation. You need to log in to Jira using the "automation.qmetry.authorization" parameter. Follow the steps below to generate basic Auth and pass it to the qmetry.properties:

Option 1

To supply a basic Auth header, perform the following steps:

  1. Build a string of the form username:password.

    Password: Password refers to the API token generated from the API Token Authentication for Jira app.

    How to generate API Token?

    1. Install the API Token Authentication for Jira app in Jira.

    2. Go to Administration and select User Management.

    3. Locate the API Token Authentication option on the navigation bar and generate the API Token. Use this API Token as a password.

  2. Encode the string in Base64 format.

  3. Supply an "Authorization" parameter with the content "Basic " followed by the encoded string. For example, the string "fred:fred" encodes to "ZnJlZDpmcmVk" in base64, so you would request as follows.

    automation.qmetry.authorization=Basic YWRtaW46YWRtaW4=

Option 2

To use a personal access token, perform the following steps:

  1. Go to User Profile.

  2. Click Personal Access Tokens and then click Create token.

  3. Supply an Authorization header with the content Bearer followed by a generated token.

    automation.qmetry.authorization=Bearer NTE1NTYzMTg4MDEzOit5OlIjghTQQEH/YZ7HNrpS

    automation.qmetry.enabled = true
    automation.qmetry.debug = true
    automation.qmetry.url=http://qtm4j-qa-postgres-datacenter.qmetry.com/rest/qtm4j/automation/latest/importresult
    automation.qmetry.apikey =88a7f1da08c39486b3c7e33cff29d00a11154d9f3705612c99192802dac8fde1421dbf79719b9f3b73dea090797210
    automation.qmetry.filepath=target/cucumber-json-report.json
    automation.qmetry.environment=env
    automation.qmetry.build=build
    automation.qmetry.attachfile=true
    automation.qmetry.matchTestSteps=true
    automation.qmetry.testCycleToReuse=NR-TR-1
    automation.qmetry.testcycle.summary=Test Cycle summary
    automation.qmetry.testcycle.labels=l1,l2,l3
    automation.qmetry.testcycle.components=c1,c2,c3
    automation.qmetry.testcycle.priority=High
    automation.qmetry.testcycle.status=To Do
    automation.qmetry.testcycle.folderPath=F1/F2/F3
    automation.qmetry.testcycle.sprintId=1242
    automation.qmetry.testcycle.fixVersionId=14234
    automation.qmetry.testcycle.description=Test Cycle description
    automation.qmetry.testcycle.assignee={Valid User Account Key}
    automation.qmetry.testcycle.reporter={Valid User Account Key}
    automation.qmetry.testcycle.plannedStartDate=15/May/2020 00:00
    automation.qmetry.testcycle.plannedEndDate=30/May/2020 00:00
    automation.qmetry.testcycle.customFields=[{"name" : "custom field 1", "value": "high,medium,low"},{"name" : "custom field 2", "value": "29/May/2020"}]
    automation.qmetry.testcase.labels=l1,l2,l3
    automation.qmetry.testcase.components=c1,c2
    automation.qmetry.testcase.priority=Medium
    automation.qmetry.testcase.status=In Progress
    automation.qmetry.testcase.folderPath=F1/F2/F3
    automation.qmetry.testcase.sprintId=34534
    automation.qmetry.testcase.fixVersionId=35345
    automation.qmetry.testcase.description=Test Case description
    automation.qmetry.testcase.precondition=Test Case precondition
    automation.qmetry.testcase.assignee={Valid User Account Key}
    automation.qmetry.testcase.reporter={Valid User Account Key}
    automation.qmetry.testcase.estimatedTime=10:10
    automation.qmetry.testcase.customFields=[{"name" : "custom field 1", "value": "high,medium,low"},{"name" : "custom field 2", "value": 10.12}]
    automation.qmetry.testCaseExecution.comment = Test Case Execution Comment
    automation.qmetry.testCaseExecution.actualTime = 10:10
    automation.qmetry.testCaseExecution.executionPlannedDate = 16/Feb/2024 
    automation.qmetry.testCaseExecution.assignee = {Valid User Account Key}
    automation.qmetry.testCaseExecution.customFields=[{"name" : "custom field 1", "value": "high,medium,low"},{"name" : "custom field 2", "value": 10.12}]
    automation.qmetry.authorization (For Basic)=Basic YWRtaW46YWRtaW4=    
    automation.qmetry.authorization (For Personal Access Token)=Bearer NTE1NTYzMTg4MDEzOit5OlIjghTQQEH/YZ7HNrpSxvcU

Once the file is configured, the automation test results will get uploaded automatically whenever the user executes the automation project (For example, using ‘mvn test’).

As an alternative to Step 3, you can also set properties with the following command with command line arguments. You can also pass multiple command-line arguments.

mvn clean test "-Dautomation.qmetry.testcycle.summary=Test Cycle Summary" "-Dautomation.qmetry.testcycle.labels=lbl1,lbl2,lbl3"

3. View imported test results

Please refer to View Imported Test Results section to view imported test results.

Publication date: