-
Notifications
You must be signed in to change notification settings - Fork 2
Test Results
A test result is the outcome of a test. It includes a pass/fail mark, and optionally a description and attachment.
In order to work with test results, make sure you have planned your test cases in a test run first.
You can create a new test result by specifying its description, category, test run, and test case.
TestResult testResult = new TestResult();
testResult
.setDescription("This is what happend!")
.setTestResultCategoryId(TestResultCategory.PASSED)
.setTestRunId(testRun.getId())
.setTestCaseId(testCase.getId());
client.testResults(project).create(testResult);
There are four test result categories available:
TestResultCategory.PASSED
TestResultCategory.CAUTION
TestResultCategory.FAILED
TestResultCategory.BLOCKING
You can add attachments using the addAttachment method:
TestResult testResult = new TestResult();
testResult
.setDescription("It didn't work!")
.setTestResultCategoryId(TestResultCategory.FAILED)
.setTestRunId(testRun.getId())
.setTestCaseId(testCase.getId());
testResult.addAttachment(new File("myFile.txt"));
client.testResults(project).create(testResult);
Please note that failed
and blocking
test results require an attachment as a default in TestMonitor. You can change this in your project settings.
Draft test results are considered as 'incomplete'. They don't have an affect on the outcome of a test case or test run. When you create a test result, the default draft state is 'true'. Make sure you set the draft state to 'false' in order to make your test results final.
If you want to add an attachment to a test result, you can use the addAttachment
method:
File file = new File(); // See the JAVA documentation on how to create or read a file object.
client.testResults(this.project).addAttachment(testResult, file);