Search in sources :

Example 1 with JunitSubmitterRequest

use of com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest in project jenkin-qtest-plugin by QASymphony.

the class TestResultFromxUnit method testParser.

@LocalData
@Test
public void testParser() throws InterruptedException, ExecutionException, TimeoutException, IOException {
    project = j.createFreeStyleProject("xunit-project");
    Configuration configuration = Configuration.newInstance();
    configuration.setReadFromJenkins(true);
    configuration.setProjectName("TestResultFromxUnitProject");
    // configuration.setAppSecretKey("34428172-cdba-4c97-aefb-b2ee5ae5db99");
    configuration.setAppSecretKey("5d65f50e-b368-47a1-9bff-e0a710011a3f");
    configuration.setReleaseId(1L);
    configuration.setId(1L);
    configuration.setProjectId(1L);
    configuration.setUrl("https://localhost:7443");
    configuration.setJenkinsProjectName("TestResultFromxUnitProject");
    configuration.setJenkinsServerUrl("http://localhost:8080/jenkins");
    TestResultFromxUnitProject testResultFromxUnitProject = new TestResultFromxUnitProject(configuration);
    configuration.setResultPattern("*.xml");
    project.getBuildersList().add(testResultFromxUnitProject);
    FreeStyleBuild build = project.scheduleBuild2(0).get(100, TimeUnit.MINUTES);
    assertNotNull("", testResultFromxUnitProject.getAutomationTestResultList());
    assertNotNull("Build is: ", build);
    String buildNumber = "1";
    String buildPath = "/jobs/TestResultFromxUnitProject/" + buildNumber;
    JunitSubmitterRequest submitterRequest = configuration.createJunitSubmitRequest();
    try {
        AutomationTestService.push(buildNumber, buildPath, testResultFromxUnitProject.getAutomationTestResultList(), submitterRequest, configuration.getAppSecretKey());
    } catch (SubmittedException e) {
        e.printStackTrace();
    }
}
Also used : SubmittedException(com.qasymphony.ci.plugin.exception.SubmittedException) Configuration(com.qasymphony.ci.plugin.model.Configuration) FreeStyleBuild(hudson.model.FreeStyleBuild) JunitSubmitterRequest(com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest) LocalData(org.jvnet.hudson.test.recipes.LocalData) Test(org.junit.Test)

Example 2 with JunitSubmitterRequest

use of com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest in project jenkin-qtest-plugin by QASymphony.

the class PipelineConfiguration method createJunitSubmitRequest.

public JunitSubmitterRequest createJunitSubmitRequest() {
    JunitSubmitterRequest request = new JunitSubmitterRequest();
    request.setqTestURL(this.qtestURL).setApiKey(this.apiKey).setConfigurationID(null).setSubmitToExistingContainer(this.submitToExistingContainer).setContainerID(containerID).setContainerType(containerType).setCreateNewTestRunsEveryBuildDate(submitToExistingContainer ? createNewTestRunsEveryBuildDate : null).setEnvironmentID(this.environmentID).setProjectID(this.projectID);
    return request;
}
Also used : JunitSubmitterRequest(com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest)

Example 3 with JunitSubmitterRequest

use of com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest in project jenkin-qtest-plugin by QASymphony.

the class JunitTestResultParserTests method testSubmitLogWithAttachment.

@Test
public void testSubmitLogWithAttachment() throws InterruptedException, ExecutionException, TimeoutException, IOException, SubmittedException {
    String buildNumber = "1";
    String buildPath = "/jobs/TestPerformance/" + buildNumber;
    String projectName = "TestPerformance";
    String apiKey = "3c76feb4-b91f-4a53-8643-bd1ce2f01a3e";
    Long releaseId = 1L;
    Long ciId = 3L;
    Long qTestProjectId = 1L;
    Configuration configuration = new Configuration(ciId, "https://localhost:7443", apiKey, qTestProjectId, projectName, releaseId, "releaseName", 0L, "environment", 0L, 0L, false, "", false, "{}", false, 0);
    List<AutomationTestResult> results = new ArrayList<>();
    long start = System.currentTimeMillis();
    int total = 1000;
    for (int i = 0; i < total; i++) {
        AutomationTestResult automationTestResult = new AutomationTestResult();
        automationTestResult.setName("Test Performance " + i);
        automationTestResult.setAutomationContent(automationTestResult.getName());
        automationTestResult.setStatus(CaseResult.Status.PASSED.toString());
        automationTestResult.setExecutedStartDate(new Date());
        automationTestResult.setExecutedEndDate(new Date());
        results.add(automationTestResult);
        List<AutomationTestStepLog> testLogs = new ArrayList<>();
        List<AutomationAttachment> automationAttachments = new ArrayList<>();
        for (int j = 0; j < 100; j++) {
            AutomationTestStepLog automationTestStepLog = new AutomationTestStepLog();
            automationTestStepLog.setOrder(j);
            automationTestStepLog.setStatus(CaseResult.Status.FAILED.toString());
            automationTestStepLog.setDescription("Test Description of " + j + " in class: " + i);
            automationTestStepLog.setExpectedResult(CaseResult.Status.FAILED.toString());
            testLogs.add(automationTestStepLog);
            AutomationAttachment automationAttachment = new AutomationAttachment();
            automationAttachment.setName(automationTestStepLog.getDescription() + ".txt");
            automationAttachment.setContentType("text/plain");
            StringBuilder sb = new StringBuilder();
            for (int k = 0; k < 10; k++) sb.append("Test attachment data");
            automationAttachment.setData(sb.toString());
            automationAttachments.add(automationAttachment);
        }
        automationTestResult.setTestLogs(testLogs);
        automationTestResult.setAttachments(automationAttachments);
    }
    JunitSubmitterRequest submitterRequest = configuration.createJunitSubmitRequest();
    AutomationTestService.push(buildNumber, buildPath, results, submitterRequest, configuration.getAppSecretKey());
    System.out.println("End submit in: " + LoggerUtils.elapsedTime(start));
}
Also used : ArrayList(java.util.ArrayList) Date(java.util.Date) JunitSubmitterRequest(com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest) Test(org.junit.Test)

Example 4 with JunitSubmitterRequest

use of com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest in project jenkin-qtest-plugin by QASymphony.

the class JunitTestResultParserTests method testSubmitLog.

@Test
public void testSubmitLog() throws InterruptedException, ExecutionException, TimeoutException, IOException, SubmittedException {
    String buildNumber = "1";
    String buildPath = "/jobs/TestPerformance/" + buildNumber;
    String projectName = "TestPerformance";
    String apiKey = "3c76feb4-b91f-4a53-8643-bd1ce2f01a3e";
    Long releaseId = 1L;
    Long ciId = 3L;
    Long qTestProjectId = 1L;
    Configuration configuration = new Configuration(ciId, "https://localhost:7443", apiKey, qTestProjectId, projectName, releaseId, "releaseName", 0L, "environment", 0L, 0L, false, "", false, "{}", false, 0);
    List<AutomationTestResult> results = new ArrayList<>();
    int total = 1000;
    for (int i = 0; i < total; i++) {
        AutomationTestResult automationTestResult = new AutomationTestResult();
        automationTestResult.setName("Test Performance " + i);
        automationTestResult.setAutomationContent(automationTestResult.getName());
        automationTestResult.setStatus(CaseResult.Status.PASSED.toString());
        automationTestResult.setExecutedStartDate(new Date());
        automationTestResult.setExecutedEndDate(new Date());
        results.add(automationTestResult);
        List<AutomationTestStepLog> testLogs = new ArrayList<>();
        for (int j = 0; j < 10; j++) {
            AutomationTestStepLog automationTestStepLog = new AutomationTestStepLog();
            automationTestStepLog.setOrder(j);
            automationTestStepLog.setStatus(CaseResult.Status.PASSED.toString());
            automationTestStepLog.setDescription("Test Description of " + j + " in class: " + i);
            automationTestStepLog.setExpectedResult(CaseResult.Status.PASSED.toString());
            testLogs.add(automationTestStepLog);
        }
        automationTestResult.setTestLogs(testLogs);
    }
    JunitSubmitterRequest submitterRequest = configuration.createJunitSubmitRequest();
    AutomationTestService.push(buildNumber, buildPath, results, submitterRequest, configuration.getAppSecretKey());
}
Also used : ArrayList(java.util.ArrayList) JunitSubmitterRequest(com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest) Date(java.util.Date) Test(org.junit.Test)

Example 5 with JunitSubmitterRequest

use of com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest in project jenkin-qtest-plugin by QASymphony.

the class JunitTestResultParserTests method testSubmitWithAutomationXMLContent.

@LocalData
@Test
public void testSubmitWithAutomationXMLContent() throws InterruptedException, ExecutionException, TimeoutException, IOException, SubmittedException {
    project = j.createFreeStyleProject("ant-project");
    automationTestResultList = null;
    project.getBuildersList().add(new JUnitParserTestAntProject());
    FreeStyleBuild build = project.scheduleBuild2(0).get(100, TimeUnit.MINUTES);
    assertNotNull("Build is: ", build);
    String buildNumber = "1";
    String buildPath = "/jobs/AntProjectWithXMLContent/" + buildNumber;
    String projectName = "AntProjectWithXMLContent";
    String apiKey = "9d3971a6-f6d7-4e0b-996c-e2ade023b4e8";
    Long releaseId = 1L;
    Long ciId = 1L;
    Long qTestProjectId = 3L;
    Configuration configuration = new Configuration(ciId, "https://localhost:7443", apiKey, qTestProjectId, projectName, releaseId, "releaseName", 0L, "environment", 0L, 0L, false, "", false, "{}", false, 0);
    JunitSubmitterRequest submitterRequest = configuration.createJunitSubmitRequest();
    submitterRequest.setBuildNumber("1").setBuildPath(buildPath);
    AutomationTestService.push(buildNumber, buildPath, automationTestResultList, submitterRequest, configuration.getAppSecretKey());
}
Also used : FreeStyleBuild(hudson.model.FreeStyleBuild) JunitSubmitterRequest(com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest) LocalData(org.jvnet.hudson.test.recipes.LocalData) Test(org.junit.Test)

Aggregations

JunitSubmitterRequest (com.qasymphony.ci.plugin.submitter.JunitSubmitterRequest)7 Test (org.junit.Test)4 FreeStyleBuild (hudson.model.FreeStyleBuild)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 LocalData (org.jvnet.hudson.test.recipes.LocalData)2 SubmittedException (com.qasymphony.ci.plugin.exception.SubmittedException)1 AutomationTestResult (com.qasymphony.ci.plugin.model.AutomationTestResult)1 Configuration (com.qasymphony.ci.plugin.model.Configuration)1 Container (com.qasymphony.ci.plugin.model.qtest.Container)1 JunitQtestSubmitterImpl (com.qasymphony.ci.plugin.submitter.JunitQtestSubmitterImpl)1 JunitSubmitter (com.qasymphony.ci.plugin.submitter.JunitSubmitter)1 JunitSubmitterResult (com.qasymphony.ci.plugin.submitter.JunitSubmitterResult)1 PrintStream (java.io.PrintStream)1