Search in sources :

Example 31 with TestResults

use of com.facebook.buck.test.TestResults 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 32 with TestResults

use of com.facebook.buck.test.TestResults 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 33 with TestResults

use of com.facebook.buck.test.TestResults 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

TestResults (com.facebook.buck.test.TestResults)33 Test (org.junit.Test)28 FakeTestResults (com.facebook.buck.test.FakeTestResults)27 TestCaseSummary (com.facebook.buck.test.TestCaseSummary)25 ImmutableList (com.google.common.collect.ImmutableList)20 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)17 ExecutionContext (com.facebook.buck.step.ExecutionContext)10 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)10 TestResultSummary (com.facebook.buck.test.TestResultSummary)10 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)8 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)8 FakeTestRule (com.facebook.buck.rules.FakeTestRule)8 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)8 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)8 BuildResult (com.facebook.buck.rules.BuildResult)6 CachingBuildEngine (com.facebook.buck.rules.CachingBuildEngine)5 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)4 Path (java.nio.file.Path)4 BuildTarget (com.facebook.buck.model.BuildTarget)3 FakeBuildEngine (com.facebook.buck.rules.FakeBuildEngine)3