Search in sources :

Example 6 with AnsiTerminalPrinter

use of com.google.devtools.build.lib.util.io.AnsiTerminalPrinter in project bazel by bazelbuild.

the class TestSummaryTest method testMessageShownForPartialResults.

@Test
public void testMessageShownForPartialResults() throws Exception {
    ImmutableList<TestCase> testCases = ImmutableList.of(newDetail("orange", TestCase.Status.FAILED, 1500L));
    TestSummary summary = createTestSummaryWithDetails(BlazeTestStatus.FAILED, testCases, FailedTestCasesStatus.PARTIAL);
    AnsiTerminalPrinter printer = Mockito.mock(AnsiTerminalPrinter.class);
    TestSummaryPrinter.print(summary, printer, true, true);
    verify(printer).print(contains("//package:name"));
    verify(printer).print(find("FAILED.*orange"));
    verify(printer).print(contains("incomplete"));
}
Also used : AnsiTerminalPrinter(com.google.devtools.build.lib.util.io.AnsiTerminalPrinter) TestCase(com.google.devtools.build.lib.view.test.TestStatus.TestCase) Test(org.junit.Test)

Example 7 with AnsiTerminalPrinter

use of com.google.devtools.build.lib.util.io.AnsiTerminalPrinter in project bazel by bazelbuild.

the class TestSummaryTest method testMessageShownWhenTestCasesMissing.

@Test
public void testMessageShownWhenTestCasesMissing() throws Exception {
    ImmutableList<TestCase> emptyList = ImmutableList.of();
    TestSummary summary = createTestSummaryWithDetails(BlazeTestStatus.FAILED, emptyList, FailedTestCasesStatus.NOT_AVAILABLE);
    AnsiTerminalPrinter printer = Mockito.mock(AnsiTerminalPrinter.class);
    TestSummaryPrinter.print(summary, printer, true, true);
    verify(printer).print(contains("//package:name"));
    verify(printer).print(contains("not available"));
}
Also used : AnsiTerminalPrinter(com.google.devtools.build.lib.util.io.AnsiTerminalPrinter) TestCase(com.google.devtools.build.lib.view.test.TestStatus.TestCase) Test(org.junit.Test)

Example 8 with AnsiTerminalPrinter

use of com.google.devtools.build.lib.util.io.AnsiTerminalPrinter in project bazel by bazelbuild.

the class TestSummaryTest method testShouldPrintFailedStatus.

@Test
public void testShouldPrintFailedStatus() throws Exception {
    String expectedString = ANY_STRING + "ERROR" + ANY_STRING + BlazeTestStatus.FAILED + ANY_STRING;
    AnsiTerminalPrinter terminalPrinter = Mockito.mock(AnsiTerminalPrinter.class);
    TestSummary summary = createTestSummary(stubTarget, BlazeTestStatus.FAILED, NOT_CACHED);
    TestSummaryPrinter.print(summary, terminalPrinter, true, false);
    terminalPrinter.print(find(expectedString));
}
Also used : AnsiTerminalPrinter(com.google.devtools.build.lib.util.io.AnsiTerminalPrinter) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 9 with AnsiTerminalPrinter

use of com.google.devtools.build.lib.util.io.AnsiTerminalPrinter in project bazel by bazelbuild.

the class TestSummaryTest method testTestCaseNamesShownWhenNeeded.

@Test
public void testTestCaseNamesShownWhenNeeded() throws Exception {
    TestCase detailPassed = newDetail("strawberry", TestCase.Status.PASSED, 1000L);
    TestCase detailFailed = newDetail("orange", TestCase.Status.FAILED, 1500L);
    TestSummary summaryPassed = createTestSummaryWithDetails(BlazeTestStatus.PASSED, Arrays.asList(detailPassed));
    TestSummary summaryFailed = createTestSummaryWithDetails(BlazeTestStatus.FAILED, Arrays.asList(detailPassed, detailFailed));
    assertEquals(BlazeTestStatus.FAILED, summaryFailed.getStatus());
    AnsiTerminalPrinter printerPassed = Mockito.mock(AnsiTerminalPrinter.class);
    TestSummaryPrinter.print(summaryPassed, printerPassed, true, true);
    verify(printerPassed).print(contains("//package:name"));
    AnsiTerminalPrinter printerFailed = Mockito.mock(AnsiTerminalPrinter.class);
    TestSummaryPrinter.print(summaryFailed, printerFailed, true, true);
    verify(printerFailed).print(contains("//package:name"));
    verify(printerFailed).print(find("FAILED.*orange *\\(1\\.5"));
}
Also used : AnsiTerminalPrinter(com.google.devtools.build.lib.util.io.AnsiTerminalPrinter) TestCase(com.google.devtools.build.lib.view.test.TestStatus.TestCase) Test(org.junit.Test)

Example 10 with AnsiTerminalPrinter

use of com.google.devtools.build.lib.util.io.AnsiTerminalPrinter in project bazel by bazelbuild.

the class TestSummaryTest method testTestCaseNamesOrdered.

@Test
public void testTestCaseNamesOrdered() throws Exception {
    TestCase[] details = { newDetail("apple", TestCase.Status.FAILED, 1000L), newDetail("banana", TestCase.Status.FAILED, 1000L), newDetail("cranberry", TestCase.Status.FAILED, 1000L) };
    // The exceedingly dumb approach: writing all the permutations down manually
    // is simply easier than any way of generating them.
    int[][] permutations = { { 0, 1, 2 }, { 0, 2, 1 }, { 1, 0, 2 }, { 1, 2, 0 }, { 2, 0, 1 }, { 2, 1, 0 } };
    for (int[] permutation : permutations) {
        List<TestCase> permutatedDetails = new ArrayList<>();
        for (int element : permutation) {
            permutatedDetails.add(details[element]);
        }
        TestSummary summary = createTestSummaryWithDetails(BlazeTestStatus.FAILED, permutatedDetails);
        // A mock that checks the ordering of method calls
        AnsiTerminalPrinter printer = Mockito.mock(AnsiTerminalPrinter.class);
        TestSummaryPrinter.print(summary, printer, true, true);
        InOrder order = Mockito.inOrder(printer);
        order.verify(printer).print(contains("//package:name"));
        order.verify(printer).print(find("FAILED.*apple"));
        order.verify(printer).print(find("FAILED.*banana"));
        order.verify(printer).print(find("FAILED.*cranberry"));
    }
}
Also used : InOrder(org.mockito.InOrder) AnsiTerminalPrinter(com.google.devtools.build.lib.util.io.AnsiTerminalPrinter) TestCase(com.google.devtools.build.lib.view.test.TestStatus.TestCase) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

AnsiTerminalPrinter (com.google.devtools.build.lib.util.io.AnsiTerminalPrinter)22 Test (org.junit.Test)20 Matchers.anyString (org.mockito.Matchers.anyString)11 TestCase (com.google.devtools.build.lib.view.test.TestStatus.TestCase)6 ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)1 ExecutionOptions (com.google.devtools.build.lib.exec.ExecutionOptions)1 AggregatingTestListener (com.google.devtools.build.lib.runtime.AggregatingTestListener)1 TestSummaryOptions (com.google.devtools.build.lib.runtime.TerminalTestResultNotifier.TestSummaryOptions)1 TestResultAnalyzer (com.google.devtools.build.lib.runtime.TestResultAnalyzer)1 Path (com.google.devtools.build.lib.vfs.Path)1 ArrayList (java.util.ArrayList)1 InOrder (org.mockito.InOrder)1