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.

unable to add plan entry to a test plan #17

@jrocketz

Description

@jrocketz

I am unable to add plan entries to a newly created test plan in TestRail using the TestRailSDK.

Steps to Reproduce

  1. Create connection to TestRailService.
  2. Get TestRail project.
  3. Create a new test plan.
  4. Create test plan entry runs.
  5. Create test plan entry.
  6. Add test plan entry to newly created test plan.

Here is the code the you can use to reproduce (Note: I have removed account and project details):

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.rmn.testrail.entity.PlanEntry;
import com.rmn.testrail.entity.PlanEntryRun;
import com.rmn.testrail.entity.Project;
import com.rmn.testrail.entity.TestPlan;
import com.rmn.testrail.entity.TestPlanCreator;
import com.rmn.testrail.service.TestRailService;

public class TestRailSDK {

    public static void main(String[] args) {

        // Create connection to TestRailService
        TestRailService testRailService = new TestRailService(clientId, username, password);
        // Get TestRail project
        Project project = testRailService.getProjectByName(projectName);
        // Create a new test plan
        TestPlanCreator testPlanCreator = new TestPlanCreator();
        testPlanCreator.setName("Test Plan");
        testPlanCreator.setAssignedToId(6);
        TestPlan testPlan = testRailService.addTestPlan(project.getId(), testPlanCreator);
        // Create test plan entry runs
        List<PlanEntryRun> planEntryRuns = new ArrayList<PlanEntryRun>();
        List<Integer> case_ids = Arrays.asList(5518,5517);
        PlanEntryRun run1 = new PlanEntryRun();
        run1.setIncludeAll(false);
        run1.setCaseIds(case_ids);
        run1.setConfigIds(Arrays.asList(2,7));
        run1.setAssignedToId(6);
        planEntryRuns.add(run1);
        PlanEntryRun run2 = new PlanEntryRun();
        run2.setIncludeAll(false);
        run2.setCaseIds(case_ids);
        run2.setConfigIds(Arrays.asList(3,7));
        run2.setAssignedToId(6);
        planEntryRuns.add(run2);
        // Create test plan entry
        PlanEntry planEntry = new PlanEntry();
        planEntry.setName("Test Plan Entry");
        planEntry.setAssignedToId(6);
        planEntry.setSuiteId(14);
        planEntry.setIncludeAll(false);
        planEntry.setRuns(planEntryRuns);
        // Add test plan entry to test plan
        PlanEntry addedPlanEntry = testRailService.addTestPlanEntry(testPlan.getId(), planEntry);
        System.out.println("Added Plan Entry: " + addedPlanEntry.getName());
    }

}

Actual Results

The test plan is created but the plan entries are not added. The following exception being thrown when attempting to print the name of the added plan entry:

Exception in thread "main" java.lang.NullPointerException
    at com.transverse.tract.TestRailSDK.main(TestRailSDK.java:51)

I verified that the case IDs are a part of the specified test suite.

{
    "created_by": 4,
    "created_on": 1427141737,
    "custom_description": null,
    "custom_expected": null,
    "custom_objective": null,
    "custom_preconds": null,
    "custom_status": 1,
    "custom_steps": null,
    "estimate": null,
    "estimate_forecast": null,
    "id": 5517,
    "milestone_id": null,
    "priority_id": 4,
    "refs": null,
    "section_id": 765,
    "suite_id": 14,
    "title": "Log in with valid username and password.",
    "type_id": 4,
    "updated_by": 4,
    "updated_on": 1427141737
}
{
    "created_by": 4,
    "created_on": 1427141737,
    "custom_description": null,
    "custom_expected": null,
    "custom_objective": null,
    "custom_preconds": null,
    "custom_status": 1,
    "custom_steps": null,
    "estimate": null,
    "estimate_forecast": null,
    "id": 5518,
    "milestone_id": null,
    "priority_id": 4,
    "refs": null,
    "section_id": 765,
    "suite_id": 14,
    "title": "Click on forgot your password link and retrieve the password for the username.",
    "type_id": 4,
    "updated_by": 4,
    "updated_on": 1427141737
}

Here is my test environment:

TestRail v4.1.0.3294 (hosted)
TestRailSDK 0.9

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