Search in sources :

Example 1 with TestSelectorList

use of com.facebook.buck.test.selectors.TestSelectorList in project buck by facebook.

the class JavaTest method getJUnitStep.

private JUnitStep getJUnitStep(ExecutionContext executionContext, SourcePathResolver pathResolver, TestRunningOptions options, Optional<Path> outDir, Optional<Path> robolectricLogPath, Set<String> testClassNames) {
    Iterable<String> reorderedTestClasses = reorderClasses(testClassNames, options.isShufflingTests());
    ImmutableList<String> properVmArgs = amendVmArgs(this.vmArgs, pathResolver, executionContext.getTargetDevice());
    BuckEventBus buckEventBus = executionContext.getBuckEventBus();
    BuildId buildId = buckEventBus.getBuildId();
    TestSelectorList testSelectorList = options.getTestSelectorList();
    JUnitJvmArgs args = JUnitJvmArgs.builder().setTestType(testType).setDirectoryForTestResults(outDir).setClasspathFile(getClassPathFile()).setTestRunnerClasspath(TESTRUNNER_CLASSES).setCodeCoverageEnabled(executionContext.isCodeCoverageEnabled()).setInclNoLocationClassesEnabled(executionContext.isInclNoLocationClassesEnabled()).setDebugEnabled(executionContext.isDebugEnabled()).setPathToJavaAgent(options.getPathToJavaAgent()).setBuildId(buildId).setBuckModuleBaseSourceCodePath(getBuildTarget().getBasePath()).setStdOutLogLevel(stdOutLogLevel).setStdErrLogLevel(stdErrLogLevel).setRobolectricLogPath(robolectricLogPath).setExtraJvmArgs(properVmArgs).addAllTestClasses(reorderedTestClasses).setShouldExplainTestSelectorList(options.shouldExplainTestSelectorList()).setTestSelectorList(testSelectorList).build();
    return new JUnitStep(getProjectFilesystem(), nativeLibsEnvironment, testRuleTimeoutMs, testCaseTimeoutMs, env, javaRuntimeLauncher, args);
}
Also used : BuckEventBus(com.facebook.buck.event.BuckEventBus) BuildId(com.facebook.buck.model.BuildId) TestSelectorList(com.facebook.buck.test.selectors.TestSelectorList)

Example 2 with TestSelectorList

use of com.facebook.buck.test.selectors.TestSelectorList in project buck by facebook.

the class TestResultFormatterTest method shouldSaySelectedTestsWillBeRun.

@Test
public void shouldSaySelectedTestsWillBeRun() {
    TestResultFormatter formatter = createSilentFormatter();
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    TestSelectorList testSelectorList = TestSelectorList.builder().addRawSelectors("com.example.clown.Car").build();
    ImmutableSet<String> targetNames = ImmutableSet.of("//:example", "//foo:bar");
    formatter.runStarted(builder, false, testSelectorList, false, targetNames, TestResultFormatter.FormatMode.BEFORE_TEST_RUN);
    assertEquals("TESTING SELECTED TESTS", toString(builder));
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) TestSelectorList(com.facebook.buck.test.selectors.TestSelectorList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Example 3 with TestSelectorList

use of com.facebook.buck.test.selectors.TestSelectorList in project buck by facebook.

the class TestResultFormatterTest method shouldExplainWhichTestsWillBeSelected.

@Test
public void shouldExplainWhichTestsWillBeSelected() {
    TestResultFormatter formatter = createSilentFormatter();
    ImmutableList.Builder<String> builder = ImmutableList.builder();
    TestSelectorList testSelectorList = TestSelectorList.builder().addRawSelectors("com.example.clown.Car").build();
    ImmutableSet<String> targetNames = ImmutableSet.of("//:example", "//foo:bar");
    boolean shouldExplain = true;
    formatter.runStarted(builder, false, testSelectorList, shouldExplain, targetNames, TestResultFormatter.FormatMode.BEFORE_TEST_RUN);
    String expected = "TESTING SELECTED TESTS\n" + "include class:com.example.clown.Car$ method:<any>\n" + "exclude everything else";
    assertEquals(expected, toString(builder));
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) TestSelectorList(com.facebook.buck.test.selectors.TestSelectorList) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Test(org.junit.Test)

Aggregations

TestSelectorList (com.facebook.buck.test.selectors.TestSelectorList)3 ImmutableList (com.google.common.collect.ImmutableList)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Test (org.junit.Test)2 BuckEventBus (com.facebook.buck.event.BuckEventBus)1 BuildId (com.facebook.buck.model.BuildId)1