Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

NullPointerException occurs when getting List<TestInstance> from a TestRun #15

@jrocketz

Description

@jrocketz

I tried to get a list of TestInstances from a TestRun, and was greeted with a NullPointerException. Here is the code that you can use to test (Note: I removed my hard-coded entries for my account and project information):

import java.util.List;
import com.rmn.testrail.entity.Project;
import com.rmn.testrail.entity.TestInstance;
import com.rmn.testrail.entity.TestPlan;
import com.rmn.testrail.entity.TestRun;
import com.rmn.testrail.entity.TestRunGroup;
import com.rmn.testrail.service.TestRailService;

public class TestRailSDK {

    public static void main(String[] args) {

        TestRailService testRailService = new TestRailService(clientId, username, password);
        Project project = testRailService.getProjectByName(projectName);
        TestPlan testPlan = project.getTestPlanByName(testPlanName);
        List<TestRunGroup> testRunGroups = testPlan.getEntries();
        for (TestRunGroup testRunGroup: testRunGroups) {
            List<TestRun> testRuns = testRunGroup.getRuns();
            for (TestRun testRun: testRuns) {
                List<TestInstance> testInstances = testRun.getTests();
            }
        }
    }

}

And the NullPointerException:

Exception in thread "main" java.lang.NullPointerException
    at com.rmn.testrail.entity.TestRun.getTests(TestRun.java:122)
    at com.transverse.tract.TestRailSDK.main(TestRailSDK.java:22

Here are the details for my test environment:

TestRail v4.1.0.3294 (Hosted)
TestRailSDK 0.9

Within my test plan, I have the following test groups and runs:

Test Run Group 1

  • Test Run (Config 1)
    • Test Instance 1
    • Test Instance 2
  • Test Run (Config 2)
    • Test Instance 3
    • Test Instance 4
  • Test Run (Config 3)
    • Test Instance 5
    • Test Instance 6
  • Test Run (Config 4)
    • Test Instance 7
    • Test Instance 8

Test Run Group 2

  • Test Run
    • Test Instance 9
    • Test Instance 10

This appears to be the offending code in TestRun.java although I can't determine why it failed:

/**
* @return the list of TestInstance entities associated with this TestRun
*/
public List<TestInstance> getTests() {
return getTestRailService().getTests( this.getId() );
}

I am able to query the TestRail v2 API directly without issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions