Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

How to add testrun to a testplan? Java api v2

#1

How do you add test runs into test plan? I really don’t understand your documentation.

Here’s what I have so far and it works:
note: connection is moved into @BeforeTest for brevity.

    /**
	 * Adds a new milestone, returns it's ID. Create a new map and feed it as data
	 */
	public Long addMilestone(Map<String, Object> data) throws IOException, APIException {
		JSONObject response = (JSONObject) client.sendPost("add_milestone/2", data);
		Long id = (Long) response.get("id");
		System.out.println(id);
		return id;
	}

	@Test
	public void createsNewMilestone() throws IOException, APIException {
		Map<String, Object> data = new HashMap<>();
		data.put("name", "New milestone added by API");
		data.put("description", "Description here");
		addMilestone(data);
	}

	/**
	 * Add test plan to a milestone, return tesplan ID
	 */
	public Long addTestplanToMilestoneReturnId(int projectId, int milestoneId, int suiteId, String testPlanName, String testPlanDescription) throws IOException, APIException {
		Map<String, Object> data = new HashMap<>();
		data.put("milestone_id", milestoneId);
		data.put("suite_id", suiteId);
		data.put("name", testPlanName);
		data.put("description", testPlanDescription);

		JSONObject obj = (JSONObject) client.sendPost("add_plan/" + projectId, data);
		Long id = (Long) obj.get("id");
		System.out.println(id);
		return id;
	}

	@Test
	public void testNewPlanCreation() throws IOException, APIException {
		addTestplanToMilestoneReturnId(2, 16, 16, "test plan added via api", "description");
	}