Search in sources :

Example 26 with TestResults

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

the class TestResultFormatterTest method allTestsPassingShouldNotEmptyTestLogs.

@Test
public void allTestsPassingShouldNotEmptyTestLogs() throws IOException {
    Path testLogPath = vfs.getPath("test-log.txt");
    Files.write(testLogPath, new byte[0]);
    TestResultFormatter formatter = createSilentFormatter();
    TestCaseSummary summary = new TestCaseSummary("com.example.FooTest", ImmutableList.of(successTest));
    TestResults results = FakeTestResults.withTestLogs(ImmutableList.of(summary), ImmutableList.of(testLogPath));
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    formatter.runComplete(builder, ImmutableList.of(results), ImmutableList.of());
    assertEquals("TESTS PASSED", toString(builder));
}
Also used : Path(java.nio.file.Path) 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 27 with TestResults

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

the class TestResultFormatterTest method shouldReportMinimalInformationForAPassingTest.

@Test
public void shouldReportMinimalInformationForAPassingTest() {
    TestResultFormatter formatter = createSilentFormatter();
    TestCaseSummary summary = new TestCaseSummary("com.example.FooTest", ImmutableList.of(successTest));
    TestResults results = FakeTestResults.of(ImmutableList.of(summary));
    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 28 with TestResults

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

the class TestResultFormatterTest method shouldUseDecimalCommaForGerman.

@Test
public void shouldUseDecimalCommaForGerman() {
    TestResultFormatter formatter = new TestResultFormatter(new Ansi(false), Verbosity.COMMANDS, TestResultSummaryVerbosity.of(false, false), Locale.GERMAN, Optional.of(logPath), TimeZone.getTimeZone("America/Los_Angeles"));
    TestCaseSummary summary = new TestCaseSummary("com.example.FooTest", ImmutableList.of(new TestResultSummary("com.example.FooTest", "successTest", ResultType.SUCCESS, 12300, /*message*/
    null, /*stacktrace*/
    null, "good stdout", "good stderr")));
    TestResults results = FakeTestResults.of(ImmutableList.of(summary));
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    formatter.reportResult(builder, results);
    assertEquals("PASS     12,3s  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) Ansi(com.facebook.buck.util.Ansi) TestResultSummary(com.facebook.buck.test.TestResultSummary) Test(org.junit.Test)

Example 29 with TestResults

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

the class TestResultFormatterTest method shouldNotOutputLogLinesOfFailingTestWhenLogIsEmpty.

@Test
public void shouldNotOutputLogLinesOfFailingTestWhenLogIsEmpty() throws IOException {
    TestResultFormatter formatter = createFormatterWithMaxLogLines(10);
    TestCaseSummary summary = new TestCaseSummary("com.example.FooTest", ImmutableList.of(failingTest));
    Files.write(logPath, new byte[0]);
    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);
    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 30 with TestResults

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

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