Search in sources :

Example 6 with CodeCoverageMetrics

use of com.uber.jenkins.phabricator.coverage.CodeCoverageMetrics in project phabricator-jenkins-plugin by uber.

the class CommentBuilderTest method testProcessWithDecreaseNotFailingTheBuild.

@Test
public void testProcessWithDecreaseNotFailingTheBuild() {
    CodeCoverageMetrics fivePercentDrop = TestUtils.getCoverageResult(100.0f, 100.0f, 100.0f, 100.0f, 95.0f);
    CommentBuilder commenter = createCommenter(Result.SUCCESS, fivePercentDrop, false, -10.0f);
    boolean passCoverage = commenter.processParentCoverage(TestUtils.getDefaultCodeCoverageMetrics(), TestUtils.TEST_SHA, FAKE_BRANCH_NAME);
    String comment = commenter.getComment();
    assertTrue(passCoverage);
    assertThat(comment, containsString("decreased (-5.000%)"));
    assertFalse(comment.contains("Build failed because coverage is lower than minimum 100.0% and decreased more than allowed 10.0%."));
}
Also used : CodeCoverageMetrics(com.uber.jenkins.phabricator.coverage.CodeCoverageMetrics) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 7 with CodeCoverageMetrics

use of com.uber.jenkins.phabricator.coverage.CodeCoverageMetrics in project phabricator-jenkins-plugin by uber.

the class UberallsClientTest method testGetCoverageWorkingBackend.

@Test
public void testGetCoverageWorkingBackend() throws IOException {
    JSONObject validJSON = TestUtils.getJSONFromFile(getClass(), "validCoverage");
    server.register("/*", TestUtils.makeHttpHandler(HttpStatus.SC_OK, validJSON.toString()));
    CodeCoverageMetrics metrics = client.getParentCoverage(TestUtils.TEST_SHA);
    assertEquals(42.0f, metrics.getLineCoveragePercent(), 0.01f);
}
Also used : CodeCoverageMetrics(com.uber.jenkins.phabricator.coverage.CodeCoverageMetrics) JSONObject(net.sf.json.JSONObject) Test(org.junit.Test)

Aggregations

CodeCoverageMetrics (com.uber.jenkins.phabricator.coverage.CodeCoverageMetrics)7 Test (org.junit.Test)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 JSONObject (net.sf.json.JSONObject)2 ConduitAPIClient (com.uber.jenkins.phabricator.conduit.ConduitAPIClient)1 ConduitAPIException (com.uber.jenkins.phabricator.conduit.ConduitAPIException)1 Differential (com.uber.jenkins.phabricator.conduit.Differential)1 DifferentialClient (com.uber.jenkins.phabricator.conduit.DifferentialClient)1 CoverageProvider (com.uber.jenkins.phabricator.coverage.CoverageProvider)1 NonDifferentialBuildTask (com.uber.jenkins.phabricator.tasks.NonDifferentialBuildTask)1 NonDifferentialHarbormasterTask (com.uber.jenkins.phabricator.tasks.NonDifferentialHarbormasterTask)1 Task (com.uber.jenkins.phabricator.tasks.Task)1 UberallsClient (com.uber.jenkins.phabricator.uberalls.UberallsClient)1 Logger (com.uber.jenkins.phabricator.utils.Logger)1 EnvVars (hudson.EnvVars)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 HashSet (java.util.HashSet)1 CauseOfInterruption (jenkins.model.CauseOfInterruption)1 InterruptedBuildAction (jenkins.model.InterruptedBuildAction)1