use of com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration in project android by JetBrains.
the class AndroidTestAndJUnitConfigurationConflictsTest method checkClassesInAllInPackage.
private void checkClassesInAllInPackage(TestSearchScope type) throws CantRunException {
Module module = ModuleManager.getInstance(myFixture.getProject()).findModuleByName("app");
assertNotNull(module);
AndroidJUnitConfiguration configuration = createConfiguration(getProject(), "google.simpleapplication", module);
configuration.getPersistentData().setScope(type);
AndroidTestPackage testPackage = new AndroidTestPackage(configuration, ExecutionEnvironmentBuilder.create(DefaultRunExecutor.getRunExecutorInstance(), configuration).build());
Set<PsiClass> myClasses = new HashSet<>();
ConfigurationUtil.findAllTestClasses(testPackage.getClassFilter(configuration.getPersistentData()), null, myClasses);
assertSize(1, myClasses);
TestArtifactSearchScopes scopes = TestArtifactSearchScopes.get(module);
assertNotNull(scopes);
assertTrue(scopes.isUnitTestSource(myClasses.iterator().next().getContainingFile().getVirtualFile()));
}
use of com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration in project android by JetBrains.
the class AndroidTestAndJUnitConfigurationConflictsTest method createConfiguration.
private static AndroidJUnitConfiguration createConfiguration(@NotNull Project project, @NotNull String packageQualifiedName, @NotNull Module module) {
AndroidJUnitConfiguration configuration = new AndroidJUnitConfiguration("", project, AndroidJUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
configuration.getPersistentData().TEST_OBJECT = JUnitConfiguration.TEST_PACKAGE;
configuration.getPersistentData().PACKAGE_NAME = packageQualifiedName;
configuration.getPersistentData().setScope(TestSearchScope.WHOLE_PROJECT);
configuration.setModule(module);
return configuration;
}
use of com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration in project android by JetBrains.
the class AndroidTestAndJUnitConfigurationConflictsTest method testDoubleClickRedirection.
public void testDoubleClickRedirection() throws Exception {
String commonTestClassName = "google.testartifacts.ExampleTest";
loadProject(TEST_ARTIFACTS_SAME_NAME_CLASSES);
Executor executor = DefaultRunExecutor.getRunExecutorInstance();
RunConfiguration jUnitConfiguration = createJUnitConfigurationFromDirectory(getProject(), "app/src/test/java");
RunConfiguration androidTestRunConfiguration = createAndroidTestConfigurationFromDirectory(getProject(), "app/src/androidTest/java");
assertNotNull(jUnitConfiguration);
assertNotNull(androidTestRunConfiguration);
SMTRunnerConsoleProperties jUnitProperties = ((AndroidJUnitConfiguration) jUnitConfiguration).createTestConsoleProperties(executor);
SMTRunnerConsoleProperties androidTestProperties = new AndroidTestConsoleProperties(androidTestRunConfiguration, executor);
PsiClass[] jUnitClasses = JavaPsiFacade.getInstance(getProject()).findClasses(commonTestClassName, jUnitProperties.getScope());
PsiClass[] aTestClasses = JavaPsiFacade.getInstance(getProject()).findClasses(commonTestClassName, androidTestProperties.getScope());
assertSize(1, jUnitClasses);
assertSize(1, aTestClasses);
assertNotSame(jUnitClasses[0], aTestClasses[0]);
}
use of com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration in project android by JetBrains.
the class TestConfigurationTesting method createConfigurationFromPsiElement.
@Nullable
private static RunConfiguration createConfigurationFromPsiElement(@NotNull Project project, @NotNull PsiElement psiElement) {
ConfigurationContext context = createContext(project, psiElement);
RunnerAndConfigurationSettings settings = context.getConfiguration();
if (settings == null) {
return null;
}
RunConfiguration configuration = settings.getConfiguration();
if (configuration instanceof AndroidTestRunConfiguration || configuration instanceof AndroidJUnitConfiguration) {
return configuration;
}
return null;
}
use of com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration in project android by JetBrains.
the class PostSyncProjectSetupTest method testJUnitRunConfigurationSetup.
public void testJUnitRunConfigurationSetup() {
when(myIdeInfo.isAndroidStudio()).thenReturn(true);
PostSyncProjectSetup.Request request = new PostSyncProjectSetup.Request();
mySetup.setUpProject(request, myProgressIndicator);
ConfigurationFactory configurationFactory = AndroidJUnitConfigurationType.getInstance().getConfigurationFactories()[0];
AndroidJUnitConfiguration jUnitConfiguration = new AndroidJUnitConfiguration("", getProject(), configurationFactory);
myRunManager.addConfiguration(myRunManager.createConfiguration(jUnitConfiguration, configurationFactory), true);
List<RunConfiguration> junitRunConfigurations = myRunManager.getConfigurationsList(AndroidJUnitConfigurationType.getInstance());
for (RunConfiguration runConfiguration : junitRunConfigurations) {
assertSize(1, myRunManager.getBeforeRunTasks(runConfiguration));
assertEquals(MakeBeforeRunTaskProvider.ID, myRunManager.getBeforeRunTasks(runConfiguration).get(0).getProviderId());
}
RunConfiguration runConfiguration = junitRunConfigurations.get(0);
List<BeforeRunTask> tasks = new LinkedList<>(myRunManager.getBeforeRunTasks(runConfiguration));
BeforeRunTask newTask = new MakeBeforeRunTaskProvider(getProject()).createTask(runConfiguration);
newTask.setEnabled(true);
tasks.add(newTask);
myRunManager.setBeforeRunTasks(runConfiguration, tasks, false);
mySetup.setUpProject(request, myProgressIndicator);
assertSize(2, myRunManager.getBeforeRunTasks(runConfiguration));
}
Aggregations