-
Notifications
You must be signed in to change notification settings - Fork 2
Test Cases
A test case describes an executable action to verify if an expected result is met.
In order to work with test cases, make sure you have created a project with a test suite first.
To get a list of test cases, use the list method:
Project project = client.projects().get(1);
ArrayList<TestCase> testCase = client.testCases(project).list();
This will get a paginated list of test cases for project ID 1.
You can request a different page and change the record limit simply by passing them as arguments:
Project project = client.projects().get(1);
ArrayList<TestCase> testCase = client.testCases(project).list(4, 10);
This will retrieve the fourth page using a list of 10 records, i.e., records 31 through 40.
To get a single test case, use the get method, which takes a test suite ID as parameter:
Project project = client.projects().get(1);
TestCase testCase = client.testCases(project).get(1);
You can access its properties by using its getters:
Project project = client.projects().get(1);
TestCase testCase = client.testCases(project).get(1);
System.out.println(testCase.getId());
System.out.println(testCase.getName());
This will output the test case ID and name.
You can create a new test case by using the create method and specifying its name as a parameter.
TestCase testCase = client.testCases(project).create("A Test Case", testSuite));
The client provides a convenient findOrCreate
method. This will try to find a test suite matching the given name first - otherwise, it will be created.
Project project = client.projects().get(1);
TestCase testCase = client.testCases(project).findOrCreate("A Test Case", testSuite));
This will look for a test case named "A Test Case"; when it's present, it will return this test case as an object. Otherwise, it will create a new test case using that name and return it as an object.
Updating a test case is just a matter of using the setters and the update method:
Project project = client.projects().get(1);
TestCase testCase = client.testCases(project).get(1);
testCase.setName("A New Name");
client.testCases(project).update(testCase);