Search in sources :

Example 1 with JacocoResultPage

use of org.jenkinsci.test.acceptance.plugins.jacoco.JacocoResultPage in project acceptance-test-harness by jenkinsci.

the class JacocoPluginTest method checkSuccessfulExecutionAndsummary.

@Test
public void checkSuccessfulExecutionAndsummary() {
    MavenInstallation.installSomeMaven(jenkins);
    FreeStyleJob job = jenkins.jobs.create();
    {
        job.copyDir(resource("/jacoco/test"));
        MavenBuildStep maven = job.addBuildStep(MavenBuildStep.class);
        maven.targets.set("clean package -B");
        maven.properties("jacoco.version=" + getJacocoLibraryVersion(), true);
        JacocoPublisher publisher = job.addPublisher(JacocoPublisher.class);
        publisher.changeBuildStatus.check();
    }
    job.save();
    Build build = job.startBuild().waitUntilFinished().shouldSucceed();
    assertThat(build, hasAction("Coverage Report"));
    JacocoResultPage total = new JacocoResultPage(build);
    assertEquals(45.45, total.instructionCoverage(), 0.01);
    assertEquals(50.0, total.branchCoverage(), 0.01);
    assertEquals(33.33, total.complexityScore(), 0.01);
    assertEquals(50.0, total.lineCoverage(), 0.01);
    assertEquals(50.0, total.methodCoverage(), 0.01);
    assertEquals(100.0, total.classCoverage(), 0.01);
    JacocoResultPage pkg = new JacocoResultPage(total, "(default)/App");
    assertEquals(45.45, pkg.instructionCoverage(), 0.01);
    assertEquals(50.0, pkg.branchCoverage(), 0.01);
    assertEquals(33.33, pkg.complexityScore(), 0.01);
    assertEquals(50.0, pkg.lineCoverage(), 0.01);
    assertEquals(50.0, pkg.methodCoverage(), 0.01);
    assertEquals(100.0, pkg.classCoverage(), 0.01);
}
Also used : JacocoResultPage(org.jenkinsci.test.acceptance.plugins.jacoco.JacocoResultPage) JacocoPublisher(org.jenkinsci.test.acceptance.plugins.jacoco.JacocoPublisher) Build(org.jenkinsci.test.acceptance.po.Build) MavenBuildStep(org.jenkinsci.test.acceptance.plugins.maven.MavenBuildStep) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Aggregations

AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)1 JacocoPublisher (org.jenkinsci.test.acceptance.plugins.jacoco.JacocoPublisher)1 JacocoResultPage (org.jenkinsci.test.acceptance.plugins.jacoco.JacocoResultPage)1 MavenBuildStep (org.jenkinsci.test.acceptance.plugins.maven.MavenBuildStep)1 Build (org.jenkinsci.test.acceptance.po.Build)1 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)1 Test (org.junit.Test)1