You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Next »

Execution results can be imported to Jira through JSON/XML representation formats specified in Import Execution Results

For each import file format, Xray provides a specific REST endpoint:

Import Tests

/api/v1/import/test/bulk[?project=keyOrId]

Check import job status

/api/v1/import/test/bulk/{jobId}/status


Import Tests

When importing tests you can use the following endpoint:

Create a job to import tests.

Request

Example 1: Tests
Example Input
[
	{
		"testtype": "Cucumber",
		"summary": "This tests the addition of 2 numbers.",
		"project": { "key": "CALC" },
		"gherkin_def": "Given I have entered <input_1> into the calculator\nAnd I have entered <input_2> into the calculator\nWhen I press <button>\nThen the result should be <output> on the screen\n\n  Examples:\n    | input_1 | input_2 | button | output |\n    | 20      | 30      | add    | 50     |\n    | 2       | 5       | add    | 7      |\n    | 0       | 40      | add    | 40     |\n    | 1       | 40      | add    | 41     |"
	},
	{
		"testtype": "Manual",
		"summary": "This tests the Subtraction of two numbers.",
		"project": { "key": "CALC" },
		"steps": [
			{
				"action": "I choose the operation of the calculator *Subtraction*",
				"data": "",
				"result": "The operation must appear selected."
			},
			{
				"action": "I enter the input into the calculator",
				"data": "I1: 5\nI2: 2",
				"result": ""
			},
			{
				"action": "I press the *Calculate* button",
				"result": "The result *3* should be displayed in the screen, on the right of the \"=\" sign."
			}
		]
	},
	{
		"testtype": "Generic",
		"summary": "CanMultiply",
		"project": { "key": "CALC" },
		"unstructured_def": "x.CalculatorTests.CanMultiply"
	}
]
Example 2: update existing Test Execution
Example Input
{
    "testExecutionKey": "DEMO-1206",
    "info" : {
        "summary" : "Execution of automated tests for release v1.3",
		"description" : "This execution is automatically created when importing execution results from an external source",
		"version" : "v1.3",
		"user" : "admin",
		"revision" : "1.0.42134",
		"startDate" : "2014-08-30T11:47:35+01:00",
		"finishDate" : "2014-08-30T11:53:00+01:00",
		"testPlanKey" : "DEMO-100",
		"testEnvironments": ["iOS", "Android"]
    },
    "tests" : [
        {
            "testKey" : "DEMO-6",
            "start" : "2014-08-30T11:47:35+01:00",
            "finish" : "2014-08-30T11:50:56+01:00",
            "comment" : "Successful execution",
            "status" : "PASS"
        }
     ]
}

Example Request

curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token"  --data @"data.json" https://xray.cloud.xpand-it.com/api/v1/import/test/bulk

Responses

200 OK : application/json : Successful. The import job was created successfully and the Job Id is provided.

Example Output
{
	"jobId":"34a4106b1d0948d1aae1170cc8df3bb4"
}


400 BAD_REQUEST : application/json : No importr test job was created. The content may be in the wrong format or a job might already be in progress.

Example Output
{
	"error":"A job to import tests is already in progress (id: 34a4106b1d0948d1aae1170cc8df3bb4)."
}



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

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


Check Import Job Status

When importing tests you can use the following endpoint:

Import tests.

Request

Example 1: Tests
Example Input
[
	{
		"testtype": "Cucumber",
		"summary": "This tests the addition of 2 numbers.",
		"project": { "key": "CALC" },
		"gherkin_def": "Given I have entered <input_1> into the calculator\nAnd I have entered <input_2> into the calculator\nWhen I press <button>\nThen the result should be <output> on the screen\n\n  Examples:\n    | input_1 | input_2 | button | output |\n    | 20      | 30      | add    | 50     |\n    | 2       | 5       | add    | 7      |\n    | 0       | 40      | add    | 40     |\n    | 1       | 40      | add    | 41     |"
	},
	{
		"testtype": "Manual",
		"summary": "This tests the Subtraction of two numbers.",
		"project": { "key": "CALC" },
		"steps": [
			{
				"action": "I choose the operation of the calculator *Subtraction*",
				"data": "",
				"result": "The operation must appear selected."
			},
			{
				"action": "I enter the input into the calculator",
				"data": "I1: 5\nI2: 2",
				"result": ""
			},
			{
				"action": "I press the *Calculate* button",
				"result": "The result *3* should be displayed in the screen, on the right of the \"=\" sign."
			}
		]
	},
	{
		"testtype": "Generic",
		"summary": "CanMultiply",
		"project": { "key": "CALC" },
		"unstructured_def": "x.CalculatorTests.CanMultiply"
	}
]
Example 2: update existing Test Execution
Example Input
{
    "testExecutionKey": "DEMO-1206",
    "info" : {
        "summary" : "Execution of automated tests for release v1.3",
		"description" : "This execution is automatically created when importing execution results from an external source",
		"version" : "v1.3",
		"user" : "admin",
		"revision" : "1.0.42134",
		"startDate" : "2014-08-30T11:47:35+01:00",
		"finishDate" : "2014-08-30T11:53:00+01:00",
		"testPlanKey" : "DEMO-100",
		"testEnvironments": ["iOS", "Android"]
    },
    "tests" : [
        {
            "testKey" : "DEMO-6",
            "start" : "2014-08-30T11:47:35+01:00",
            "finish" : "2014-08-30T11:50:56+01:00",
            "comment" : "Successful execution",
            "status" : "PASS"
        }
     ]
}

Example Request

curl -H "Content-Type: application/json" -X POST -H "Authorization: Bearer $token"  --data @"data.json" https://xray.cloud.xpand-it.com/api/v1/import/test/bulk

Responses

200 OK : application/json : Successful. The import job was created successfully and the Job Id is provided.

Example Output
{
	"jobId":"34a4106b1d0948d1aae1170cc8df3bb4"
}


400 BAD_REQUEST : application/json : No importr test job was created. The content may be in the wrong format or a job might already be in progress.

Example Output
{
	"error":"A job to import tests is already in progress (id: 34a4106b1d0948d1aae1170cc8df3bb4)."
}



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

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

  • No labels