/** Test method create project */ @Test public void testCreateProject() { String method = "testCreateProject()"; TestLinkTest test = new TestLinkTest() { public void runTest(String version, TestLinkAPIClient api) throws Exception { Integer id = api.createTestProject( JUNIT_DYNAMIC_PROJECT, JUNIT_DYNAMIC_PREFIX, JUNIT_DYNAMIC_PROJECT + " created by JUnit test."); if (id == null) { throw new Exception("Unable to create project."); } } }; // Run test and record failure if it happens RunExceptionResults results = runner.runTest(method, test); if (results == null || results.containsFailure()) { fail( "Failed to run TestLink API " + method + " method. Version=" + ((results == null) ? null : results.getLatestFailedVersion())); } }
/** Test reporting a test result by project, plan build, and case name */ @Test public void testReportTestCaseResultByBuild() { String method = "testReportTestCaseResultByBuild()"; TestLinkTest test = new TestLinkTest() { public void runTest(String version, TestLinkAPIClient api) throws Exception { String caseVisibleID = TestLinkAPIHelper.getCaseVisibleID(api, JUNIT_STATIC_PROJECT, JUNIT_DYNAMIC_CASE); TestLinkAPIResults results = api.reportTestCaseResult( JUNIT_STATIC_PROJECT, JUNIT_STATIC_TEST_PLAN, caseVisibleID, JUNIT_DYNAMIC_BUILD, "The test was by JUnit run on " + new Date().toString(), TEST_PASSED); if (results == null) { throw new Exception("Unable to add test case to test plan suite."); } } }; // Run test and record failure if it happens RunExceptionResults results = runner.runTest(method, test); if (results == null || results.containsFailure()) { fail( "Failed to run TestLink API " + method + " method. Version=" + ((results == null) ? null : results.getLatestFailedVersion())); } }
/** Test method create test case */ @Test public void testCreateTestCase() { String method = "testCreateTestCase()"; TestLinkTest test = new TestLinkTest() { public void runTest(String version, TestLinkAPIClient api) throws Exception { Integer id = api.createTestCase( "admin", JUNIT_DYNAMIC_PROJECT, JUNIT_DYNAMIC_SUITE, JUNIT_DYNAMIC_CASE, "JUnit created summary.", "JUnit created steps.", "JUnit created expected results.", HIGH); if (id == null || id.intValue() == 0) { throw new Exception("Failed to create a test case for project " + JUNIT_DYNAMIC_CASE); } } }; // Run test and record failure if it happens RunExceptionResults results = runner.runTest(method, test); if (results == null || results.containsFailure()) { fail( "Failed to run TestLink API " + method + " method. Version=" + ((results == null) ? null : results.getLatestFailedVersion())); } }
/** Test method create test case with all parameters */ @Test public void testCreateTestCaseWithAllParametersAuto() { String method = "testCreateTestCaseWithAllParametersAuto()"; TestLinkTest test = new TestLinkTest() { public void runTest(String version, TestLinkAPIClient api) throws Exception { Integer projectID = TestLinkAPIHelper.getProjectID(api, JUNIT_DYNAMIC_PROJECT); Integer suiteID = TestLinkAPIHelper.getSuiteID(api, JUNIT_DYNAMIC_PROJECT, JUNIT_DYNAMIC_SUITE); Integer id = api.createTestCase( "admin", projectID, suiteID, JUNIT_DYNAMIC_CASE, "JUnit created summary.", "JUnit created steps.", "JUnit created expected results.", new Integer(3), null, new Boolean(true), ACTION_GEN_NEW_ON_DUP, TESTCASE_EXECUTION_TYPE_AUTO, MEDIUM); if (id == null) { throw new Exception("Failed to create a test case for project " + JUNIT_DYNAMIC_CASE); } } }; // Run test and record failure if it happens RunExceptionResults results = runner.runTest(method, test); if (results == null || results.containsFailure()) { fail( "Failed to run TestLink API " + method + " method. Version=" + ((results == null) ? null : results.getLatestFailedVersion())); } }
/** Test method add test case (static plan case) to test plan */ @Test public void testAddTestPlanCaseToTestPlan() { String method = "testAddTestPlanCaseToTestPlan()"; TestLinkTest test = new TestLinkTest() { public void runTest(String version, TestLinkAPIClient api) throws Exception { Integer id = api.createTestCase( "admin", JUNIT_STATIC_PROJECT, JUNIT_STATIC_SUITE, JUNIT_STATIC_CASE, "JUnit created summary.", "JUnit created steps.", "JUnit created expected results.", HIGH); if (id == null) { throw new Exception("Unable to add test case to test plan suite."); } TestLinkAPIResults added = api.addTestCaseToTestPlan( JUNIT_STATIC_PROJECT, JUNIT_STATIC_TEST_PLAN, JUNIT_STATIC_CASE); if (added == null) { throw new Exception("Unable to add test case to test plan."); } } }; // Run test and record failure if it happens RunExceptionResults results = runner.runTest(method, test); if (results == null || results.containsFailure()) { fail( "Failed to run TestLink API " + method + " method. Version=" + ((results == null) ? null : results.getLatestFailedVersion())); } }
/** Test method that gets the created projects */ @Test public void testGetProjects() { String method = "testGetProjects()"; TestLinkTest test = new TestLinkTest() { public void runTest(String version, TestLinkAPIClient api) throws Exception { TestLinkAPIResults results = api.getProjects(); if (results == null || results.size() == 0) { throw new Exception( "Failed to get at least the project that would have been created by the test."); } } }; // Run test and record failure if it happens RunExceptionResults results = runner.runTest(method, test); if (results == null || results.containsFailure()) { fail( "Failed to run TestLink API " + method + " method. Version=" + ((results == null) ? null : results.getLatestFailedVersion())); } }
/** * Test method create test plan. * * <p>TestLink does not offer a createTestPlan procedure at this time so it will need to be * created manually. This procedure will test of the project, suite and cases so that the test * plan can be setup. */ @Test public void testCreateTestPlan() { String method = "testCreateTestPlan()"; TestLinkTest test = new TestLinkTest() { public void runTest(String version, TestLinkAPIClient api) throws Exception { Integer projectID = TestLinkAPIHelper.getProjectID(api, JUNIT_STATIC_PROJECT); if (projectID == null) { projectID = api.createTestProject( JUNIT_STATIC_PROJECT, "mytest", JUNIT_STATIC_PROJECT + " created by JUnit test."); } Integer suiteID = TestLinkAPIHelper.getSuiteID(api, JUNIT_STATIC_PROJECT, JUNIT_STATIC_SUITE); if (suiteID == null) { suiteID = api.createTestSuite( JUNIT_STATIC_PROJECT, JUNIT_STATIC_SUITE, "This suite was created by a JUnit test."); } Integer caseID = TestLinkAPIHelper.getCaseIDByName(api, projectID, suiteID, JUNIT_STATIC_CASE); if (caseID == null) { caseID = api.createTestCase( "admin", JUNIT_STATIC_PROJECT, JUNIT_STATIC_SUITE, JUNIT_STATIC_CASE, "JUnit created summary.", "JUnit created steps.", "JUnit created expected results.", HIGH); } /* * TestLink API does not offer test plan creation so check that * the test plan has been manually created for future testing. */ Integer planID = TestLinkAPIHelper.getPlanID(api, projectID, JUNIT_STATIC_TEST_PLAN); if (planID == null || planID.intValue() == 0) { throw new TestLinkAPIException("The JUnit test plan was not found."); } } }; // Run test and record failure if it happens RunExceptionResults results = runner.runTest(method, test); if (results == null || results.containsFailure()) { fail( "Failed to run TestLink API " + method + " method. Version=" + ((results == null) ? null : results.getLatestFailedVersion())); } }