Skip to content

Test Runs

Thijs Kok edited this page Jan 26, 2022 · 6 revisions

A test run is a composition of test cases to be tested by one or more testers in a specific timeframe.

In order to work with test runs, make sure you have created a project with a milestone first.

Get a list of test runs

To get a list of test runs, use the list method:

Project project = client.projects().get(1);
ArrayList<TestRun> testRun = client.testRuns(project).list();

This will get a paginated list of test runs for project ID 1.

Pagination

You can request a different page and change the record limit simply by passing them as arguments:

Project project = client.projects().get(1);
ArrayList<TestRun> testRun = client.testRuns(project).list(4, 10);

This will retrieve the fourth page using a list of 10 records, i.e., records 31 through 40.

Get a single test run

To get a single test run, use the get method, which takes a test run ID as parameter:

Project project = client.projects().get(1);
TestRun testRun = client.testRuns(project).get(1);

You can access its properties by using its getters:

Project project = client.projects().get(1);
TestRun testRun = client.testRuns(project).get(1);

System.out.println(testRun.getId());
System.out.println(testRun.getName());

This will output the test run ID and name.

Create a test run

You can create a new test run by using the create method and specifying its name as a parameter.

Project project = client.projects().get(1);
Milestone milestone = client.milestones().get(1);
TestRun testRun = client.testRuns(project).create("A Test Run", milestone));

The client provides a convenient findOrCreate method. This will try to find a test run matching the given name first - otherwise, it will be created.

Milestone milestone = client.milestones().get(1);
TestRun testRun = client.testRuns(project).findOrCreate("A Test Run", milestone));

This will look for a test run named "A Test Run"; when it's present, it will return this test run as an object. Otherwise, it will create a new test run using that name and return it as an object.

Assigning users

You can use the assignUsers method to assign users to your test runs. You need to specify the test run and a list of user id's. You can add yourself to a test run following the example below:

List<Integer> users = new ArrayList<>();
users.add(client.users().authenticatedUser().getId());
client.testRuns(project).assignUsers(testRun, users);

Assigning test cases

You can use the assignTestCases method to assign test cases to your test runs. You need to specify the test run and a list of test case id's:

List<Integer> testCases = new ArrayList<>();
testCases.add(1);
testCases.add(myTestCase.getId());
client.testRuns(project).assignTestCases(testRun, testCases);

Updating a test run

Updating a test run is just a matter of using the setters and the update method:

Project project = client.projects().get(1);
TestRun testRun = client.testRuns(project).get(1);

testRun.setName("A New Name");

client.testRuns(project).update(testRun);
Clone this wiki locally