@Test public void runTests() { final ImmutableList<String> command = ImmutableList.of("hello", "world"); FakeCxxTest cxxTest = new FakeCxxTest() { @Override protected ImmutableList<String> getShellCommand(ExecutionContext context, Path output) { return command; } }; BuildContext buildContext = FakeBuildContext.NOOP_CONTEXT; ExecutionContext executionContext = TestExecutionContext.newInstance(); TestRunningOptions options = TestRunningOptions.builder() .setDryRun(false) .setTestSelectorList(TestSelectorList.empty()) .build(); ImmutableList<Step> actualSteps = cxxTest.runTests( buildContext, executionContext, options, FakeTestRule.NOOP_REPORTING_CALLBACK); CxxTestStep cxxTestStep = new CxxTestStep( new FakeProjectFilesystem(), command, ImmutableMap.<String, String>of(), cxxTest.getPathToTestExitCode(), cxxTest.getPathToTestOutput(), TEST_TIMEOUT_MS); assertEquals(cxxTestStep, Iterables.getLast(actualSteps)); }
@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 Path getPathToOutput() { return 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( ExecutionContext context, 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, /* isDryRun */ false); result.call(); }