Package org.sonar.api.test

Examples of org.sonar.api.test.MutableTestCase


    DefaultTestPlan plan = beanGraph.createVertex(DefaultTestPlan.class);
    plan.addTestCase("T1");
    plan.addTestCase("T2");

    DefaultTestable testable = beanGraph.createVertex(DefaultTestable.class);
    MutableTestCase testCase1 = Iterables.get(plan.testCases(), 0);
    testCase1.setCoverageBlock(testable, Arrays.asList(10, 11, 12));
    MutableTestCase testCase2 = Iterables.get(plan.testCases(), 1);
    testCase2.setCoverageBlock(testable, Arrays.asList(12, 48, 49));

    assertThat(testable.testCaseByName("T1")).isEqualTo(testCase1);
    assertThat(testable.testCaseByName("T2")).isEqualTo(testCase2);
    assertThat(testable.testCaseByName("Unknown")).isNull();
  }
View Full Code Here


    DefaultTestable testable2 = beanGraph.createAdjacentVertex(file2, DefaultTestable.class, "testable");

    DefaultTestPlan plan = beanGraph.createVertex(DefaultTestPlan.class);
    plan.addTestCase("T1");

    MutableTestCase testCase = Iterables.get(plan.testCases(), 0);
    testCase.setCoverageBlock(testable1, Arrays.asList(10, 11, 12));

    assertThat(testable1.coverageBlock(testCase).testCase()).isEqualTo(testCase);
    assertThat(testable1.coverageBlock(testCase).testable()).isEqualTo(testable1);
    assertThat(testable2.coverageBlock(testCase)).isNull();
  }
View Full Code Here

    DefaultTestPlan plan = beanGraph.createVertex(DefaultTestPlan.class);
    plan.addTestCase("T1");
    plan.addTestCase("T2");

    assertThat(plan.testCases()).hasSize(2);
    MutableTestCase firstTestCase = Iterables.get(plan.testCases(), 0);
    assertThat(firstTestCase.name()).isEqualTo("T1");
    assertThat(firstTestCase.testPlan()).isSameAs(plan);

    MutableTestCase secondTestCase = Iterables.get(plan.testCases(), 1);
    assertThat(secondTestCase.name()).isEqualTo("T2");
    assertThat(secondTestCase.testPlan()).isSameAs(plan);
  }
View Full Code Here

  public void show() throws Exception {
    MockUserSession.set().addComponentPermission(UserRole.CODEVIEWER, "SonarQube", TEST_PLAN_KEY);

    when(snapshotPerspectives.as(MutableTestPlan.class, TEST_PLAN_KEY)).thenReturn(testPlan);

    MutableTestCase testCase1 = testCase("test1", TestCase.Status.OK, 10L, 32, null, null);
    MutableTestCase testCase2 = testCase("test2", TestCase.Status.ERROR, 97L, 21, "expected:<true> but was:<false>",
      "java.lang.AssertionError: expected:<true> but was:<false>\n\t" +
        "at org.junit.Assert.fail(Assert.java:91)\n\t" +
        "at org.junit.Assert.failNotEquals(Assert.java:645)\n\t" +
        "at org.junit.Assert.assertEquals(Assert.java:126)\n\t" +
        "at org.junit.Assert.assertEquals(Assert.java:145)\n");
View Full Code Here

    request.execute().assertJson(getClass(), "show_from_test_data_with_a_time_in_float.json");
  }

  private MutableTestCase testCase(String name, TestCase.Status status, Long durationInMs, int coveredLines, @Nullable String message, @Nullable String stackTrace) {
    MutableTestCase testCase = mock(MutableTestCase.class);
    when(testCase.name()).thenReturn(name);
    when(testCase.status()).thenReturn(status);
    when(testCase.durationInMs()).thenReturn(durationInMs);
    when(testCase.countCoveredLines()).thenReturn(coveredLines);
    when(testCase.message()).thenReturn(message);
    when(testCase.stackTrace()).thenReturn(stackTrace);
    return testCase;
  }
View Full Code Here

  @Test
  public void plan() throws Exception {
    MockUserSession.set().addComponentPermission(UserRole.CODEVIEWER, "SonarQube", TEST_PLAN_KEY);

    MutableTestCase testCase1 = testCase("org.foo.Bar.java", "src/main/java/org/foo/Bar.java", 10);
    MutableTestCase testCase2 = testCase("org.foo.File.java", "src/main/java/org/foo/File.java", 3);
    when(testPlan.testCasesByName("my_test")).thenReturn(newArrayList(testCase1, testCase2));

    WsTester.TestRequest request = tester.newGetRequest("api/tests", "covered_files").setParam("key", TEST_PLAN_KEY).setParam("test", "my_test");

    request.execute().assertJson("{\n" +
View Full Code Here

    CoverageBlock block = mock(CoverageBlock.class);
    when(block.testable()).thenReturn(testable);
    when(block.lines()).thenReturn(Arrays.asList(new Integer[coveredLines]));

    MutableTestCase testCase = mock(MutableTestCase.class);
    when(testCase.coverageBlocks()).thenReturn(newArrayList(block));
    return testCase;
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.test.MutableTestCase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.