use of com.intellij.execution.junit.JUnitConfiguration in project intellij-community by JetBrains.
the class RerunFailedTestsAction method getRunProfile.
@Override
protected MyRunProfile getRunProfile(@NotNull ExecutionEnvironment environment) {
//noinspection ConstantConditions
final JUnitConfiguration configuration = (JUnitConfiguration) myConsoleProperties.getConfiguration();
final TestMethods testMethods = new TestMethods(configuration, environment, getFailedTests(configuration.getProject()));
return new MyRunProfile(configuration) {
@Override
@NotNull
public Module[] getModules() {
return testMethods.getModulesToCompile();
}
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) {
testMethods.clear();
return testMethods;
}
};
}
use of com.intellij.execution.junit.JUnitConfiguration in project android by JetBrains.
the class AndroidJUnitConfigurations method isFromContext.
// Copy of JUnitConfigurationProducer#isConfigurationFromContext using AndroidJUnitConfigurationType instead of JUnitConfigurationType
public static boolean isFromContext(@NotNull JUnitConfiguration unitConfiguration, @NotNull ConfigurationContext context, @NotNull ConfigurationFactory configurationFactory) {
if (RunConfigurationProducer.getInstance(PatternConfigurationProducer.class).isMultipleElementsSelected(context)) {
return false;
}
RunConfiguration predefinedConfiguration = context.getOriginalConfiguration(AndroidJUnitConfigurationType.getInstance());
Location contextLocation = context.getLocation();
String paramSetName = contextLocation instanceof PsiMemberParameterizedLocation ? ((PsiMemberParameterizedLocation) contextLocation).getParamSetName() : null;
assert contextLocation != null;
Location location = JavaExecutionUtil.stepIntoSingleClass(contextLocation);
if (location == null) {
return false;
}
PsiElement element = location.getPsiElement();
PsiClass testClass = getTestClass(element);
PsiMethod testMethod = getTestMethod(element, false);
PsiPackage testPackage;
if (element instanceof PsiPackage) {
testPackage = (PsiPackage) element;
} else {
if (element instanceof PsiDirectory) {
testPackage = JavaDirectoryService.getInstance().getPackage(((PsiDirectory) element));
} else {
testPackage = null;
}
}
PsiDirectory testDir = element instanceof PsiDirectory ? (PsiDirectory) element : null;
RunnerAndConfigurationSettings template = RunManager.getInstance(location.getProject()).getConfigurationTemplate(configurationFactory);
Module predefinedModule = ((JUnitConfiguration) template.getConfiguration()).getConfigurationModule().getModule();
String vmParameters = predefinedConfiguration instanceof JUnitConfiguration ? ((JUnitConfiguration) predefinedConfiguration).getVMParameters() : null;
if (vmParameters != null && !Comparing.strEqual(vmParameters, unitConfiguration.getVMParameters())) {
return false;
}
if (paramSetName != null && !Comparing.strEqual(paramSetName, unitConfiguration.getProgramParameters())) {
return false;
}
TestObject testobject = unitConfiguration.getTestObject();
if (testobject != null) {
if (testobject.isConfiguredByElement(unitConfiguration, testClass, testMethod, testPackage, testDir)) {
Module configurationModule = unitConfiguration.getConfigurationModule().getModule();
if (Comparing.equal(location.getModule(), configurationModule)) {
return true;
}
if (Comparing.equal(predefinedModule, configurationModule)) {
return true;
}
}
}
return false;
}
use of com.intellij.execution.junit.JUnitConfiguration in project android by JetBrains.
the class AndroidTestPackage method getClassFilter.
@Override
@VisibleForTesting
public TestClassFilter getClassFilter(JUnitConfiguration.Data data) throws CantRunException {
TestClassFilter classFilter = super.getClassFilter(data);
JUnitConfiguration configuration = getConfiguration();
Module[] modules = configuration instanceof AndroidJUnitConfiguration ? ((AndroidJUnitConfiguration) configuration).getModulesToCompile() : configuration.getModules();
for (Module module : modules) {
TestArtifactSearchScopes testArtifactSearchScopes = TestArtifactSearchScopes.get(module);
if (testArtifactSearchScopes != null) {
classFilter = classFilter.intersectionWith(testArtifactSearchScopes.getAndroidTestExcludeScope());
}
}
return classFilter;
}
Aggregations