Search in sources :

Example 31 with TestCaseSummary

use of com.facebook.buck.test.TestCaseSummary in project buck by facebook.

the class TestResultFormatterTest method shouldIndicateThatNoTestRanIfNoneRanAndUsingFilter.

@Test
public void shouldIndicateThatNoTestRanIfNoneRanAndUsingFilter() {
    TestResultFormatter formatter = createSilentFormatter();
    TestCaseSummary summary = new TestCaseSummary("com.example.FooTest", ImmutableList.of());
    TestResults results = FakeTestResults.of(ImmutableList.of(summary));
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    formatter.runComplete(builder, ImmutableList.of(results), ImmutableList.of());
    assertThat(toString(builder), containsString("NO TESTS RAN"));
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) TestCaseSummary(com.facebook.buck.test.TestCaseSummary) FakeTestResults(com.facebook.buck.test.FakeTestResults) TestResults(com.facebook.buck.test.TestResults) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 32 with TestCaseSummary

use of com.facebook.buck.test.TestCaseSummary in project buck by facebook.

the class TestResultFormatterTest method shouldNotOutputStackTraceStdOutAndStdErrOfFailingTest.

@Test
public void shouldNotOutputStackTraceStdOutAndStdErrOfFailingTest() {
    TestResultFormatter formatter = createSilentFormatter();
    TestCaseSummary summary = new TestCaseSummary("com.example.FooTest", ImmutableList.of(failingTest));
    TestResults results = FakeTestResults.of(ImmutableList.of(summary));
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    formatter.reportResult(builder, results);
    String expected = String.format(Joiner.on('\n').join("FAIL     200ms  0 Passed   0 Skipped   1 Failed   com.example.FooTest", "FAILURE %s %s: %s", "%s"), failingTest.getTestCaseName(), failingTest.getTestName(), failingTest.getMessage(), stackTrace);
    assertEquals(expected, toString(builder));
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) TestCaseSummary(com.facebook.buck.test.TestCaseSummary) FakeTestResults(com.facebook.buck.test.FakeTestResults) TestResults(com.facebook.buck.test.TestResults) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 33 with TestCaseSummary

use of com.facebook.buck.test.TestCaseSummary in project buck by facebook.

the class TestResultFormatterTest method shouldNotOutputLogPathInlineForPassingTest.

@Test
public void shouldNotOutputLogPathInlineForPassingTest() throws IOException {
    TestResultFormatter formatter = createFormatterWithMaxLogLines(10);
    TestCaseSummary summary = new TestCaseSummary("com.example.FooTest", ImmutableList.of(successTest));
    Files.write(logPath, ImmutableList.of("This is a debug log", "Here's another one"), StandardCharsets.UTF_8);
    TestResults results = TestResults.builder().setBuildTarget(BuildTargetFactory.newInstance("//foo:bar")).setTestCases(ImmutableList.of(summary)).addTestLogPaths(logPath).build();
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    formatter.reportResult(builder, results);
    assertEquals("PASS     500ms  1 Passed   0 Skipped   0 Failed   com.example.FooTest", toString(builder));
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) TestCaseSummary(com.facebook.buck.test.TestCaseSummary) FakeTestResults(com.facebook.buck.test.FakeTestResults) TestResults(com.facebook.buck.test.TestResults) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 34 with TestCaseSummary

use of com.facebook.buck.test.TestCaseSummary in project buck by facebook.

the class TestResultFormatterTest method shouldOutputStackTraceStdOutAndStdErrOfFailingTest.

@Test
public void shouldOutputStackTraceStdOutAndStdErrOfFailingTest() {
    TestResultFormatter formatter = createNoisyFormatter();
    TestCaseSummary summary = new TestCaseSummary("com.example.FooTest", ImmutableList.of(failingTest));
    TestResults results = FakeTestResults.of(ImmutableList.of(summary));
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    formatter.reportResult(builder, results);
    String expected = String.format(Joiner.on('\n').join("FAIL     200ms  0 Passed   0 Skipped   1 Failed   com.example.FooTest", "FAILURE %s %s: %s", "%s", "====STANDARD OUT====", "%s", "====STANDARD ERR====", "%s"), failingTest.getTestCaseName(), failingTest.getTestName(), failingTest.getMessage(), stackTrace, failingTest.getStdOut(), failingTest.getStdErr());
    assertEquals(expected, toString(builder));
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) TestCaseSummary(com.facebook.buck.test.TestCaseSummary) FakeTestResults(com.facebook.buck.test.FakeTestResults) TestResults(com.facebook.buck.test.TestResults) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Aggregations

TestCaseSummary (com.facebook.buck.test.TestCaseSummary)34 Test (org.junit.Test)28 TestResults (com.facebook.buck.test.TestResults)25 FakeTestResults (com.facebook.buck.test.FakeTestResults)22 ImmutableList (com.google.common.collect.ImmutableList)18 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)17 TestResultSummary (com.facebook.buck.test.TestResultSummary)16 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)7 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)7 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)7 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)7 Path (java.nio.file.Path)7 BuildTarget (com.facebook.buck.model.BuildTarget)6 RuleKey (com.facebook.buck.rules.RuleKey)6 FakeTestRule (com.facebook.buck.rules.FakeTestRule)4 ExecutionContext (com.facebook.buck.step.ExecutionContext)4 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)4 ActionGraphEvent (com.facebook.buck.event.ActionGraphEvent)3 BuckEventBus (com.facebook.buck.event.BuckEventBus)3 ConsoleTestUtils.postStoreFinished (com.facebook.buck.event.listener.ConsoleTestUtils.postStoreFinished)3