Search in sources :

Example 1 with JUnitResultArchiver

use of hudson.tasks.junit.JUnitResultArchiver in project blueocean-plugin by jenkinsci.

the class PipelineApiTest method getPipelineRunWithTestResult.

@Test
public void getPipelineRunWithTestResult() throws Exception {
    FreeStyleProject p = j.createFreeStyleProject("pipeline4");
    p.getBuildersList().add(new Shell("echo '<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<testsuite xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd\" name=\"io.jenkins.blueocean.jsextensions.JenkinsJSExtensionsTest\" time=\"35.7\" tests=\"1\" errors=\"0\" skipped=\"0\" failures=\"0\">\n" + "  <properties>\n" + "  </properties>\n" + "  <testcase name=\"test\" classname=\"io.jenkins.blueocean.jsextensions.JenkinsJSExtensionsTest\" time=\"34.09\"/>\n" + "</testsuite>' > test-result.xml"));
    p.getPublishersList().add(new JUnitResultArchiver("*.xml"));
    FreeStyleBuild b = p.scheduleBuild2(0).get();
    TestResultAction resultAction = b.getAction(TestResultAction.class);
    assertEquals("io.jenkins.blueocean.jsextensions.JenkinsJSExtensionsTest", resultAction.getResult().getSuites().iterator().next().getName());
    j.assertBuildStatusSuccess(b);
    Map resp = get("/organizations/jenkins/pipelines/pipeline4/runs/" + b.getId());
    //discover TestResultAction super classes
    get("/classes/hudson.tasks.junit.TestResultAction/");
    // get junit rest report
    get("/organizations/jenkins/pipelines/pipeline4/runs/" + b.getId() + "/testReport/result/");
}
Also used : Shell(hudson.tasks.Shell) JUnitResultArchiver(hudson.tasks.junit.JUnitResultArchiver) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) TestResultAction(hudson.tasks.junit.TestResultAction) Test(org.junit.Test)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 FreeStyleBuild (hudson.model.FreeStyleBuild)1 FreeStyleProject (hudson.model.FreeStyleProject)1 Shell (hudson.tasks.Shell)1 JUnitResultArchiver (hudson.tasks.junit.JUnitResultArchiver)1 TestResultAction (hudson.tasks.junit.TestResultAction)1 Map (java.util.Map)1 Test (org.junit.Test)1