use of com.intellij.execution.testframework.SearchForTestsTask in project intellij-community by JetBrains.
the class TestPackage method createSearchingForTestsTask.
@Override
public SearchForTestsTask createSearchingForTestsTask() {
final JUnitConfiguration.Data data = getConfiguration().getPersistentData();
return new SearchForTestsTask(getConfiguration().getProject(), myServerSocket) {
private final THashSet<PsiClass> myClasses = new THashSet<>();
@Override
protected void search() {
myClasses.clear();
final SourceScope sourceScope = getSourceScope();
final Module module = getConfiguration().getConfigurationModule().getModule();
if (sourceScope != null && !ReadAction.compute(() -> isJUnit5(module, sourceScope, myProject))) {
try {
final TestClassFilter classFilter = getClassFilter(data);
LOG.assertTrue(classFilter.getBase() != null);
ConfigurationUtil.findAllTestClasses(classFilter, module, myClasses);
} catch (CantRunException ignored) {
}
}
}
@Override
protected void onFound() {
try {
addClassesListToJavaParameters(myClasses, psiClass -> psiClass != null ? JavaExecutionUtil.getRuntimeQualifiedName(psiClass) : null, getPackageName(data), createTempFiles(), getJavaParameters());
} catch (ExecutionException ignored) {
}
}
};
}
use of com.intellij.execution.testframework.SearchForTestsTask in project intellij-community by JetBrains.
the class TestsPattern method createSearchingForTestsTask.
@Override
public SearchForTestsTask createSearchingForTestsTask() {
final JUnitConfiguration.Data data = getConfiguration().getPersistentData();
final Project project = getConfiguration().getProject();
final Set<String> classNames = new LinkedHashSet<>();
for (String className : data.getPatterns()) {
final PsiClass psiClass = getTestClass(project, className);
if (psiClass != null && JUnitUtil.isTestClass(psiClass)) {
classNames.add(className);
}
}
if (classNames.size() == data.getPatterns().size()) {
return new SearchForTestsTask(project, myServerSocket) {
@Override
protected void search() throws ExecutionException {
final Function<String, String> nameFunction = StringUtil.isEmpty(data.METHOD_NAME) ? FunctionUtil.<String>id() : (Function<String, String>) className -> className;
addClassesListToJavaParameters(classNames, nameFunction, "", false, getJavaParameters());
}
@Override
protected void onFound() {
}
};
}
return super.createSearchingForTestsTask();
}
use of com.intellij.execution.testframework.SearchForTestsTask in project intellij-community by JetBrains.
the class TestObject method createHandler.
@NotNull
protected OSProcessHandler createHandler(Executor executor) throws ExecutionException {
appendForkInfo(executor);
final String repeatMode = getConfiguration().getRepeatMode();
if (!RepeatCount.ONCE.equals(repeatMode)) {
final int repeatCount = getConfiguration().getRepeatCount();
final String countString = RepeatCount.N.equals(repeatMode) && repeatCount > 0 ? RepeatCount.getCountString(repeatCount) : repeatMode;
getJavaParameters().getProgramParametersList().add(countString);
}
final OSProcessHandler processHandler = new KillableColoredProcessHandler(createCommandLine());
ProcessTerminatedListener.attach(processHandler);
final SearchForTestsTask searchForTestsTask = createSearchingForTestsTask();
if (searchForTestsTask != null) {
searchForTestsTask.attachTaskToProcess(processHandler);
}
return processHandler;
}
use of com.intellij.execution.testframework.SearchForTestsTask in project intellij-community by JetBrains.
the class ConfigurationsTest method checkCanRun.
private static JavaParameters checkCanRun(RunConfiguration configuration) throws ExecutionException {
final RunProfileState state;
state = ExecutionEnvironmentBuilder.create(DefaultRunExecutor.getRunExecutorInstance(), configuration).build().getState();
assertNotNull(state);
assertTrue(state instanceof JavaCommandLine);
if (state instanceof TestPackage) {
@SuppressWarnings("UnusedDeclaration") final JavaParameters parameters = ((TestPackage) state).getJavaParameters();
final SearchForTestsTask task = ((TestPackage) state).createSearchingForTestsTask();
assertNotNull(task);
task.startSearch();
}
try {
configuration.checkConfiguration();
} catch (RuntimeConfigurationError e) {
fail("cannot run: " + e.getMessage());
} catch (RuntimeConfigurationException e) {
//ignore
}
return ((JavaCommandLine) state).getJavaParameters();
}
Aggregations