Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titlePOST /api/v2/import/execution/robot/multipart
Panel
borderColor#ccc
borderStylesolid

Imports the execution results from Robot Framework XML output format. For more information please check the documentation about Robot Framework integration.

Request

Example

Code Block
titleRobot Report XML
<?xml version="1.0" encoding="UTF-8"?>
<robot generated="20170220 14:18:54.562" generator="Robot 3.0.2 (Python 2.7.13 on win32)">
  <suite source="C:\Users\lmfv\Documents\Saco de Features\xray-1238\robot-example\robotframework-webdemo\login_tests" id="s1" name="Login Tests">
    <suite source="C:\Users\lmfv\Documents\Saco de Features\xray-1238\robot-example\robotframework-webdemo\login_tests\gherkin_login.robot" id="s1-s1" name="Gherkin Login">
      <test id="s1-s1-t1" name="Gherkin Valid Login">
        <kw name="Given browser is opened to login page">
          <kw name="Login Page Should Be Open" library="resource">
            <kw name="Title Should Be" library="Selenium2Library">
              <doc>Verifies that current page title equals `title`.</doc>
              <arguments>
                <arg>Log in - Your Company JIRA</arg>
              </arguments>
              <msg timestamp="20170220 14:19:07.693" level="INFO">Page title is 'Log in - Your Company JIRA'.</msg>
              <status status="PASS" endtime="20170220 14:19:07.693" starttime="20170220 14:19:07.158">
              </status>
            </kw>
            <status status="PASS" endtime="20170220 14:19:07.693" starttime="20170220 14:19:07.158">
            </status>
          </kw>
          <status status="PASS" endtime="20170220 14:19:07.693" starttime="20170220 14:18:55.937">
          </status>
        </kw>
        <kw name="When user &quot;admin&quot; logs in with password &quot;password123&quot;">
          <kw name="Input Username" library="resource">
            <arguments>
              <arg>${username}</arg>
            </arguments>
            <kw name="Input Text" library="Selenium2Library">
              <doc>Types the given `text` into text field identified by `locator`.</doc>
              <arguments>
                <arg>login-form-username</arg>
                <arg>${username}</arg>
              </arguments>
              <msg timestamp="20170220 14:19:07.696" level="INFO">Typing text 'admin' into text field 'login-form-username'</msg>
              <status status="PASS" endtime="20170220 14:19:09.314" starttime="20170220 14:19:07.696">
              </status>
            </kw>
            <status status="PASS" endtime="20170220 14:19:09.314" starttime="20170220 14:19:07.695">
            </status>
          </kw>
          <kw name="Input Password" library="resource">
            <arguments>
              <arg>${password}</arg>
            </arguments>
            <kw name="Input Text" library="Selenium2Library">
              <doc>Types the given `text` into text field identified by `locator`.</doc>
              <arguments>
                <arg>login-form-password</arg>
                <arg>${password}</arg>
              </arguments>
              <msg timestamp="20170220 14:19:09.316" level="INFO">Typing text 'password123' into text field 'login-form-password'</msg>
              <status status="PASS" endtime="20170220 14:19:10.956" starttime="20170220 14:19:09.316">
              </status>
            </kw>
            <status status="PASS" endtime="20170220 14:19:10.956" starttime="20170220 14:19:09.315">
            </status>
          </kw>
          <kw name="Submit Credentials" library="resource">
            <kw name="Click Button" library="Selenium2Library">
              <doc>Clicks a button identified by `locator`.</doc>
              <arguments>
                <arg>login-form-submit</arg>
              </arguments>
              <msg timestamp="20170220 14:19:10.958" level="INFO">Clicking button 'login-form-submit'.</msg>
              <status status="PASS" endtime="20170220 14:19:17.476" starttime="20170220 14:19:10.958">
              </status>
            </kw>
            <status status="PASS" endtime="20170220 14:19:17.477" starttime="20170220 14:19:10.957">
            </status>
          </kw>
          <status status="PASS" endtime="20170220 14:19:17.478" starttime="20170220 14:19:07.695">
          </status>
        </kw>
        <kw name="Then welcome page should be open" library="resource">
          <kw name="Location Should Be" library="Selenium2Library">
            <doc>Verifies that current URL is exactly `url`.</doc>
            <arguments>
              <arg>${WELCOME URL}</arg>
            </arguments>
            <kw name="Capture Page Screenshot" library="Selenium2Library">
              <doc>Takes a screenshot of the current page and embeds it into the log.</doc>
              <msg timestamp="20170220 14:19:18.702" html="yes" level="INFO">&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td colspan="3"&gt;&lt;a href="selenium-screenshot-1.png"&gt;&lt;img src="selenium-screenshot-1.png" width="800px"&gt;&lt;/a&gt;</msg>
              <status status="PASS" endtime="20170220 14:19:18.702" starttime="20170220 14:19:18.004">
              </status>
            </kw>
            <msg timestamp="20170220 14:19:18.705" level="FAIL">Location should have been 'http://localhost:8080/secure/Dashboard.jspa' but was 'http://localhost:8080/login.jsp'</msg>
            <status status="FAIL" endtime="20170220 14:19:18.705" starttime="20170220 14:19:17.483">
            </status>
          </kw>
          <status status="FAIL" endtime="20170220 14:19:18.706" starttime="20170220 14:19:17.481">
          </status>
        </kw>
        <kw type="teardown" name="Close Browser" library="Selenium2Library">
          <doc>Closes the current browser.</doc>
          <status status="PASS" endtime="20170220 14:19:22.382" starttime="20170220 14:19:18.707">
          </status>
        </kw>
        <tags>
          <tag>WEB-1</tag>
          <tag>WEB-3</tag>
        </tags>
        <status status="FAIL" endtime="20170220 14:19:22.383" critical="yes" starttime="20170220 14:18:55.936">Location should have been 'http://localhost:8080/secure/Dashboard.jspa' but was 'http://localhost:8080/login.jsp'</status>
      </test>
      <doc>A test suite with a single Gherkin style test.This test is functionally identical to the example invalid_login.robot file.</doc>
      <status status="FAIL" endtime="20170220 14:19:22.397" starttime="20170220 14:18:54.670">
      </status>
    </suite>
    <status status="FAIL" endtime="20170220 14:22:12.549" starttime="20170220 14:18:54.567">
    </status>
  </suite>
</robot>


Code Block
titleInfo JSON (Test Execution)
{
    "fields": {
        "project": {
            "id": "10402"
        },
        "summary": "Brand new Test execution",
        "issuetype": {
            "id": "10007"
        },
        "components" : [
            {
            "name":"Interface"
            },
            {
            "name":"Core"
            }
        ]
    },
	"xrayFields": {
		"testPlanKey": "DEMO-15",
		"environments": ["Chrome", "Windows"]
	}
}
Code Block
titleInfo JSON (Test)
{
    "fields": {
        "project": {
            "id": "10402"
        },
        "labels" : ["Server","Robot"]
    }
}


Tip
titleExample Request

curl -H "Content-Type: multipart/form-data" -X POST -F info=@issueFields.json -F results=@results.xml -F testInfo=@testIssueFields.json -H "Authorization: Bearer $token" https://xray.cloud.getxray.app/api/v2/import/execution/robot/multipart

Responses

200 OK : application/json : Successful. The results were successfully imported to Jira.

Code Block
titleExample Output
{
  "id": "10200",
  "key": "DEMO-24",
  "self": "https://www.example.com/rest/api/2/issue/10200"
}

400 BAD_REQUEST : application/json : Returns the error.

401 UNAUTHORIZED : application/json : The Xray license is not valid.

500  INTERNAL SERVER ERROR : application/json : An internal error occurred when importing execution results.

Behave JSON results

After executing Behave features, you must import the outputted JSON execution results to Jira using the following endpoint:

 

Expand
titlePOST /api/v2/import/execution/behave
Panel
borderColor#ccc
borderStylesolid

Import the execution results created with the Behave JSON output formatter.

Request

Example
Code Block
titleExample Input
[
{
  "elements": [
    {
      "keyword": "Background",
      "location": "features/tutorial09_background.feature:3",
      "name": "Ninja fight setup",
      "steps": [
        {
          "keyword": "Given",
          "location": "features/tutorial09_background.feature:4",
          "name": "the ninja encounters another opponent",
          "step_type": "given"
        }
      ],
      "type": "background"
    },
    {
      "keyword": "Scenario",
      "location": "features/tutorial09_background.feature:7",
      "name": "Weaker opponent",
      "status": "passed",
      "steps": [
        {
          "keyword": "Given",
          "location": "features/tutorial09_background.feature:4",
          "match": {
            "arguments": [],
            "location": "features/steps/step_tutorial02.py:78"
          },
          "name": "the ninja encounters another opponent",
          "result": {
            "duration": 0.0007519721984863281,
            "status": "passed"
          },
          "step_type": "given"
        },
        {
          "keyword": "Given",
          "location": "features/tutorial09_background.feature:8",
          "match": {
            "arguments": [
              {
                "name": "achievement_level",
                "value": "third level black-belt"
              }
            ],
            "location": "features/steps/step_tutorial02.py:57"
          },
          "name": "the ninja has a third level black-belt",
          "result": {
            "duration": 8.988380432128906e-05,
            "status": "passed"
          },
          "step_type": "given"
        },
        {
          "keyword": "When",
          "location": "features/tutorial09_background.feature:9",
          "match": {
            "arguments": [
              {
                "name": "opponent_role",
                "value": "samurai"
              }
            ],
            "location": "features/steps/step_tutorial02.py:61"
          },
          "name": "attacked by a samurai",
          "result": {
            "duration": 6.29425048828125e-05,
            "status": "passed"
          },
          "step_type": "when"
        },
        {
          "keyword": "Then",
          "location": "features/tutorial09_background.feature:10",
          "match": {
            "arguments": [
              {
                "name": "reaction",
                "value": "engage the opponent"
              }
            ],
            "location": "features/steps/step_tutorial02.py:69"
          },
          "name": "the ninja should engage the opponent",
          "result": {
            "duration": 7.295608520507812e-05,
            "status": "passed"
          },
          "step_type": "then"
        }
      ],
      "tags": [
        "TEST_DEMO-3",
        "TESTSET_DEMO-6",
        "REQ_DEMO-7"
      ],
      "type": "scenario"
    },
    {
      "keyword": "Scenario",
      "location": "features/tutorial09_background.feature:13",
      "name": "Stronger opponent",
      "status": "passed",
      "steps": [
        {
          "keyword": "Given",
          "location": "features/tutorial09_background.feature:4",
          "match": {
            "arguments": [],
            "location": "features/steps/step_tutorial02.py:78"
          },
          "name": "the ninja encounters another opponent",
          "result": {
            "duration": 8.487701416015625e-05,
            "status": "passed"
          },
          "step_type": "given"
        },
        {
          "keyword": "Given",
          "location": "features/tutorial09_background.feature:14",
          "match": {
            "arguments": [
              {
                "name": "achievement_level",
                "value": "second level black-belt"
              }
            ],
            "location": "features/steps/step_tutorial02.py:57"
          },
          "name": "the ninja has a second level black-belt",
          "result": {
            "duration": 8.130073547363281e-05,
            "status": "passed"
          },
          "step_type": "given"
        },
        {
          "keyword": "When",
          "location": "features/tutorial09_background.feature:15",
          "match": {
            "arguments": [
              {
                "name": "opponent",
                "value": "Chuck Norris"
              }
            ],
            "location": "features/steps/step_tutorial02.py:65"
          },
          "name": "attacked by Chuck Norris",
          "result": {
            "duration": 6.127357482910156e-05,
            "status": "passed"
          },
          "step_type": "when"
        },
        {
          "keyword": "Then",
          "location": "features/tutorial09_background.feature:16",
          "match": {
            "arguments": [
              {
                "name": "reaction",
                "value": "run for his life"
              }
            ],
            "location": "features/steps/step_tutorial02.py:69"
          },
          "name": "the ninja should run for his life",
          "result": {
            "duration": 8.821487426757812e-05,
            "status": "passed"
          },
          "step_type": "then"
        }
      ],
      "tags": [
        "TEST_DEMO-4",
        "TESTSET_DEMO-6",
        "REQ_DEMO-7"
      ],
      "type": "scenario"
    }
  ],
  "keyword": "Feature",
  "location": "features/tutorial09_background.feature:1",
  "name": "Using Background -- Fight or Flight",
  "status": "passed",
  "tags": []
}
]
Tip
titleExample Request

curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token"  --data @"data.json" https://xray.cloud.getxray.app/api/v2/import/execution/behave

Responses

200 OK : application/json : Successful. The results were successfully imported to Jira.

Code Block
titleExample Output
{
  "id": "10200",
  "key": "XNP-24",
  "self": "https://www.example.com/rest/api/2/issue/10200"
}


400 BAD_REQUEST : application/json : No execution results were provided.

401 UNAUTHORIZED : application/json : The Xray license is not valid.

500  INTERNAL SERVER ERROR : application/json : An internal error occurred when importing execution results.

Behave JSON results Multipart

Xray provides another endpoint if you want to create new Test Executions and have control over newly-created Test Execution fields. It allows you to send two JSON files, the normal Behave result JSON and a JSON similar to the one Jira uses to create new issues. For more information about that second format, check the Jira documentation here.

 

Expand
titlePOST /api/v2/import/execution/behave/multipart
Panel
borderColor#ccc
borderStylesolid

Import the execution results created with the Behave JSON output formatter.

Request

Example
Code Block
titleExample Input
[
{
  "elements": [
    {
      "keyword": "Background",
      "location": "features/tutorial09_background.feature:3",
      "name": "Ninja fight setup",
      "steps": [
        {
          "keyword": "Given",
          "location": "features/tutorial09_background.feature:4",
          "name": "the ninja encounters another opponent",
          "step_type": "given"
        }
      ],
      "type": "background"
    },
    {
      "keyword": "Scenario",
      "location": "features/tutorial09_background.feature:7",
      "name": "Weaker opponent",
      "status": "passed",
      "steps": [
        {
          "keyword": "Given",
          "location": "features/tutorial09_background.feature:4",
          "match": {
            "arguments": [],
            "location": "features/steps/step_tutorial02.py:78"
          },
          "name": "the ninja encounters another opponent",
          "result": {
            "duration": 0.0007519721984863281,
            "status": "passed"
          },
          "step_type": "given"
        },
        {
          "keyword": "Given",
          "location": "features/tutorial09_background.feature:8",
          "match": {
            "arguments": [
              {
                "name": "achievement_level",
                "value": "third level black-belt"
              }
            ],
            "location": "features/steps/step_tutorial02.py:57"
          },
          "name": "the ninja has a third level black-belt",
          "result": {
            "duration": 8.988380432128906e-05,
            "status": "passed"
          },
          "step_type": "given"
        },
        {
          "keyword": "When",
          "location": "features/tutorial09_background.feature:9",
          "match": {
            "arguments": [
              {
                "name": "opponent_role",
                "value": "samurai"
              }
            ],
            "location": "features/steps/step_tutorial02.py:61"
          },
          "name": "attacked by a samurai",
          "result": {
            "duration": 6.29425048828125e-05,
            "status": "passed"
          },
          "step_type": "when"
        },
        {
          "keyword": "Then",
          "location": "features/tutorial09_background.feature:10",
          "match": {
            "arguments": [
              {
                "name": "reaction",
                "value": "engage the opponent"
              }
            ],
            "location": "features/steps/step_tutorial02.py:69"
          },
          "name": "the ninja should engage the opponent",
          "result": {
            "duration": 7.295608520507812e-05,
            "status": "passed"
          },
          "step_type": "then"
        }
      ],
      "tags": [
        "TEST_DEMO-3",
        "TESTSET_DEMO-6",
        "REQ_DEMO-7"
      ],
      "type": "scenario"
    },
    {
      "keyword": "Scenario",
      "location": "features/tutorial09_background.feature:13",
      "name": "Stronger opponent",
      "status": "passed",
      "steps": [
        {
          "keyword": "Given",
          "location": "features/tutorial09_background.feature:4",
          "match": {
            "arguments": [],
            "location": "features/steps/step_tutorial02.py:78"
          },
          "name": "the ninja encounters another opponent",
          "result": {
            "duration": 8.487701416015625e-05,
            "status": "passed"
          },
          "step_type": "given"
        },
        {
          "keyword": "Given",
          "location": "features/tutorial09_background.feature:14",
          "match": {
            "arguments": [
              {
                "name": "achievement_level",
                "value": "second level black-belt"
              }
            ],
            "location": "features/steps/step_tutorial02.py:57"
          },
          "name": "the ninja has a second level black-belt",
          "result": {
            "duration": 8.130073547363281e-05,
            "status": "passed"
          },
          "step_type": "given"
        },
        {
          "keyword": "When",
          "location": "features/tutorial09_background.feature:15",
          "match": {
            "arguments": [
              {
                "name": "opponent",
                "value": "Chuck Norris"
              }
            ],
            "location": "features/steps/step_tutorial02.py:65"
          },
          "name": "attacked by Chuck Norris",
          "result": {
            "duration": 6.127357482910156e-05,
            "status": "passed"
          },
          "step_type": "when"
        },
        {
          "keyword": "Then",
          "location": "features/tutorial09_background.feature:16",
          "match": {
            "arguments": [
              {
                "name": "reaction",
                "value": "run for his life"
              }
            ],
            "location": "features/steps/step_tutorial02.py:69"
          },
          "name": "the ninja should run for his life",
          "result": {
            "duration": 8.821487426757812e-05,
            "status": "passed"
          },
          "step_type": "then"
        }
      ],
      "tags": [
        "TEST_DEMO-4",
        "TESTSET_DEMO-6",
        "REQ_DEMO-7"
      ],
      "type": "scenario"
    }
  ],
  "keyword": "Feature",
  "location": "features/tutorial09_background.feature:1",
  "name": "Using Background -- Fight or Flight",
  "status": "passed",
  "tags": []
}
]
Code Block
titleInfo JSON (Test Execution)
{
    "fields": {
        "project": {
            "key": "DEMO"
        },
        "summary": "Brand new Test execution (behave multipart)",
        "issuetype": {
            "id": "10008"
        }
    },
    "xrayFields": {
        "testPlanKey": "DEMO-9"
    }
}
Tip
titleExample Request

curl -H "Content-Type: multipart/form-data" -X POST -F info=@issueFields.json -F results=@results.json -H "Authorization: Bearer $token" https://xray.cloud.getxray.app/api/v2/import/execution/behave/multipart

Responses

200 OK : application/json : Successful. The results were successfully imported to Jira.

Code Block
titleExample Output
{
  "id": "10200",
  "key": "DEMO-24",
  "self": "https://www.example.com/rest/api/2/issue/10200"
}


400 BAD_REQUEST : application/json : No execution results were provided.

401 UNAUTHORIZED : application/json : The Xray license is not valid.

500  INTERNAL SERVER ERROR : application/json : An internal error occurred when importing execution results.