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));
}
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));
}
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));
}
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));
}
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"));
}
Aggregations