use of com.facebook.buck.test.TestResults in project buck by facebook.
the class TestRunningTest method testIsTestRunRequiredForTestInDebugMode.
@Test
public void testIsTestRunRequiredForTestInDebugMode() throws IOException, ExecutionException, InterruptedException {
ExecutionContext executionContext = TestExecutionContext.newBuilder().setDebugEnabled(true).build();
assertTrue(executionContext.isDebugEnabled());
assertTrue("In debug mode, test should always run regardless of any cached results since " + "the user is expecting to hook up a debugger.", TestRunning.isTestRunRequiredForTest(createMock(TestRule.class), createMock(CachingBuildEngine.class), executionContext, createMock(TestRuleKeyFileHelper.class), TestRunningOptions.TestResultCacheMode.ENABLED, Callables.<TestResults>returning(null), false, /* hasEnvironmentOverrides */
false));
}
use of com.facebook.buck.test.TestResults in project buck by facebook.
the class CxxTestTest method interpretResults.
@Test
public void interpretResults() throws Exception {
final Path expectedExitCode = Paths.get("output");
final Path expectedOutput = Paths.get("output");
final Path expectedResults = Paths.get("results");
FakeCxxTest cxxTest = new FakeCxxTest() {
@Override
public SourcePath getSourcePathToOutput() {
return new ExplicitBuildTargetSourcePath(getBuildTarget(), Paths.get("output"));
}
@Override
protected Path getPathToTestExitCode() {
return expectedExitCode;
}
@Override
protected Path getPathToTestOutput() {
return expectedOutput;
}
@Override
protected Path getPathToTestResults() {
return expectedResults;
}
@Override
protected ImmutableList<TestResultSummary> parseResults(Path exitCode, Path output, Path results) throws Exception {
assertEquals(expectedExitCode, exitCode);
assertEquals(expectedOutput, output);
assertEquals(expectedResults, results);
return ImmutableList.of();
}
};
ExecutionContext executionContext = TestExecutionContext.newInstance();
Callable<TestResults> result = cxxTest.interpretTestResults(executionContext, /* isUsingTestSelectors */
false);
result.call();
}
use of com.facebook.buck.test.TestResults in project buck by facebook.
the class TestResultFormatterTest method shouldReportTheNumberOfFailingTestsWithMoreThanOneTest.
@Test
public void shouldReportTheNumberOfFailingTestsWithMoreThanOneTest() {
TestResultFormatter formatter = createSilentFormatter();
TestCaseSummary summary = new TestCaseSummary("com.example.FooTest", ImmutableList.of(successTest, failingTest, new TestResultSummary("com.example.FooTest", "anotherFail", ResultType.FAILURE, 200, "Unexpected fnord found", null, null, null)));
TestResults results = TestResults.of(BuildTargetFactory.newInstance("//foo:bar"), ImmutableList.of(summary), /* contacts */
ImmutableSet.of(), /* labels */
ImmutableSet.of());
ImmutableList.Builder<String> builder = ImmutableList.builder();
formatter.runComplete(builder, ImmutableList.of(results), ImmutableList.of());
String expectedOutput = Joiner.on('\n').join("TESTS FAILED: 2 FAILURES", "Failed target: //foo:bar", "FAIL com.example.FooTest");
assertEquals(expectedOutput, toString(builder));
}
use of com.facebook.buck.test.TestResults in project buck by facebook.
the class TestResultFormatterTest method shouldNotOutputLogLinesOfFailingTestIfMaxLinesIsZero.
@Test
public void shouldNotOutputLogLinesOfFailingTestIfMaxLinesIsZero() throws IOException {
TestResultFormatter formatter = createFormatterWithMaxLogLines(0);
TestCaseSummary summary = new TestCaseSummary("com.example.FooTest", ImmutableList.of(failingTest));
Files.write(logPath, ImmutableList.of("None", "of", "these", "will", "appear"), 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);
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 failingTestShouldShowTestStatusMessages.
@Test
public void failingTestShouldShowTestStatusMessages() throws IOException {
TestResultFormatter formatter = createSilentFormatter();
TestCaseSummary summary = new TestCaseSummary("com.example.FooTest", ImmutableList.of(successTest, failingTest));
TestResults results = TestResults.of(BuildTargetFactory.newInstance("//foo:bar"), ImmutableList.of(summary), /* contacts */
ImmutableSet.of(), /* labels */
ImmutableSet.of());
ImmutableList.Builder<String> builder = ImmutableList.builder();
formatter.runComplete(builder, ImmutableList.of(results), ImmutableList.of(TestStatusMessage.of("Hello world", Level.INFO, 1450473060000L)));
String expectedOutput = Joiner.on('\n').join("====TEST STATUS MESSAGES====", "[2015-12-18 13:11:00.000][INFO] Hello world", "TESTS FAILED: 1 FAILURE", "Failed target: //foo:bar", "FAIL com.example.FooTest");
assertEquals(expectedOutput, toString(builder));
}
Aggregations