use of org.jetbrains.plugins.gradle.execution.test.runner.GradleSMTestProxy in project intellij-community by JetBrains.
the class BeforeTestEvent method process.
@Override
public void process(@NotNull final TestEventXmlView eventXml) throws TestEventXmlView.XmlParserException {
final String testId = eventXml.getTestId();
final String parentTestId = eventXml.getTestParentId();
final String name = eventXml.getTestName();
final String fqClassName = eventXml.getTestClassName();
String locationUrl = findLocationUrl(name, fqClassName);
final GradleSMTestProxy testProxy = new GradleSMTestProxy(name, false, locationUrl, fqClassName);
testProxy.setStarted();
testProxy.setLocator(getExecutionConsole().getUrlProvider());
registerTestProxy(testId, testProxy);
if (StringUtil.isEmpty(parentTestId)) {
addToInvokeLater(() -> getResultsViewer().getTestsRootNode().addChild(testProxy));
} else {
final SMTestProxy parentTestProxy = findTestProxy(parentTestId);
if (parentTestProxy != null) {
addToInvokeLater(() -> {
final List<GradleSMTestProxy> notYetAddedParents = ContainerUtil.newSmartList();
SMTestProxy currentParentTestProxy = parentTestProxy;
while (currentParentTestProxy != null && currentParentTestProxy instanceof GradleSMTestProxy) {
final String parentId = ((GradleSMTestProxy) currentParentTestProxy).getParentId();
if (currentParentTestProxy.getParent() == null && parentId != null) {
notYetAddedParents.add((GradleSMTestProxy) currentParentTestProxy);
}
currentParentTestProxy = findTestProxy(parentId);
}
for (GradleSMTestProxy gradleSMTestProxy : ContainerUtil.reverse(notYetAddedParents)) {
final SMTestProxy parentTestProxy1 = findTestProxy(gradleSMTestProxy.getParentId());
if (parentTestProxy1 != null) {
parentTestProxy1.addChild(gradleSMTestProxy);
getResultsViewer().onSuiteStarted(gradleSMTestProxy);
}
}
parentTestProxy.addChild(testProxy);
});
}
}
addToInvokeLater(() -> getResultsViewer().onTestStarted(testProxy));
}
use of org.jetbrains.plugins.gradle.execution.test.runner.GradleSMTestProxy in project intellij-community by JetBrains.
the class BeforeSuiteEvent method process.
@Override
public void process(@NotNull final TestEventXmlView eventXml) throws TestEventXmlView.XmlParserException {
final String testId = eventXml.getTestId();
final String parentTestId = eventXml.getTestParentId();
final String name = eventXml.getTestName();
final String fqClassName = eventXml.getTestClassName();
if (StringUtil.isEmpty(parentTestId)) {
registerTestProxy(testId, getResultsViewer().getTestsRootNode());
} else {
String locationUrl = findLocationUrl(null, fqClassName);
final GradleSMTestProxy testProxy = new GradleSMTestProxy(name, true, locationUrl, null);
testProxy.setLocator(getExecutionConsole().getUrlProvider());
testProxy.setParentId(parentTestId);
testProxy.setStarted();
registerTestProxy(testId, testProxy);
}
}
use of org.jetbrains.plugins.gradle.execution.test.runner.GradleSMTestProxy in project intellij-community by JetBrains.
the class GradleRerunFailedTestsAction method getRunProfile.
@Nullable
@Override
protected MyRunProfile getRunProfile(@NotNull ExecutionEnvironment environment) {
ExternalSystemRunConfiguration configuration = (ExternalSystemRunConfiguration) myConsoleProperties.getConfiguration();
final List<AbstractTestProxy> failedTests = getFailedTests(configuration.getProject());
return new MyRunProfile(configuration) {
@NotNull
@Override
public Module[] getModules() {
return Module.EMPTY_ARRAY;
}
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment environment) throws ExecutionException {
ExternalSystemRunConfiguration runProfile = ((ExternalSystemRunConfiguration) getPeer()).clone();
Project project = runProfile.getProject();
Set<String> scriptParameters = ContainerUtil.newLinkedHashSet();
Set<String> tasksToRun = ContainerUtil.newLinkedHashSet();
boolean useResolvedTasks = true;
for (AbstractTestProxy test : failedTests) {
if (test instanceof GradleSMTestProxy) {
String testName = test.getName();
String className = ((GradleSMTestProxy) test).getClassName();
scriptParameters.add(TestMethodGradleConfigurationProducer.createTestFilter(className, testName));
if (!useResolvedTasks)
continue;
if (className == null) {
useResolvedTasks = false;
continue;
}
final PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(className, GlobalSearchScope.projectScope(project));
if (psiClass == null) {
useResolvedTasks = false;
continue;
}
final PsiFile psiFile = psiClass.getContainingFile();
if (psiFile == null) {
useResolvedTasks = false;
continue;
}
final Module moduleForFile = ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(psiFile.getVirtualFile());
if (moduleForFile == null) {
useResolvedTasks = false;
continue;
}
ContainerUtil.addAllNotNull(tasksToRun, GradleTestRunConfigurationProducer.getTasksToRun(moduleForFile));
}
}
runProfile.getSettings().setScriptParameters(StringUtil.join(scriptParameters, " "));
if (useResolvedTasks && !tasksToRun.isEmpty()) {
runProfile.getSettings().setTaskNames(ContainerUtil.newArrayList(tasksToRun));
}
return runProfile.getState(executor, environment);
}
};
}
Aggregations