Search in sources :

Example 1 with AndroidTestRunConfiguration

use of com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration in project android by JetBrains.

the class AndroidProgramRunner method doExecute.

@Override
protected RunContentDescriptor doExecute(@NotNull final RunProfileState state, @NotNull final ExecutionEnvironment env) throws ExecutionException {
    boolean showRunContent = env.getRunProfile() instanceof AndroidTestRunConfiguration;
    RunnerAndConfigurationSettings runnerAndConfigurationSettings = env.getRunnerAndConfigurationSettings();
    if (runnerAndConfigurationSettings != null) {
        runnerAndConfigurationSettings.setActivateToolWindowBeforeRun(showRunContent);
    }
    RunContentDescriptor descriptor = super.doExecute(state, env);
    if (descriptor != null) {
        ProcessHandler processHandler = descriptor.getProcessHandler();
        assert processHandler != null;
        RunProfile runProfile = env.getRunProfile();
        int uniqueId = runProfile instanceof RunConfigurationBase ? ((RunConfigurationBase) runProfile).getUniqueID() : -1;
        AndroidSessionInfo sessionInfo = new AndroidSessionInfo(processHandler, descriptor, uniqueId, env.getExecutor().getId(), InstantRunUtils.isInstantRunEnabled(env));
        processHandler.putUserData(AndroidSessionInfo.KEY, sessionInfo);
    }
    return descriptor;
}
Also used : RunConfigurationBase(com.intellij.execution.configurations.RunConfigurationBase) RunContentDescriptor(com.intellij.execution.ui.RunContentDescriptor) AndroidTestRunConfiguration(com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ProcessHandler(com.intellij.execution.process.ProcessHandler) RunProfile(com.intellij.execution.configurations.RunProfile)

Example 2 with AndroidTestRunConfiguration

use of com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration in project android by JetBrains.

the class AndroidTestAndJUnitConfigurationConflictsTest method testConfigurationsAreDifferent.

// See http://b.android.com/215255
public void testConfigurationsAreDifferent() throws Exception {
    loadSimpleApplication();
    if (SystemInfo.isWindows) {
        // Do not run tests on Windows (see http://b.android.com/222904)
        return;
    }
    RunConfiguration androidTestRunConfiguration = createAndroidTestConfigurationFromDirectory(getProject(), "app/src/androidTest/java");
    RunConfiguration jUnitConfiguration = createJUnitConfigurationFromDirectory(getProject(), "app/src/test/java");
    assertNotNull(jUnitConfiguration);
    assertNotNull(androidTestRunConfiguration);
    assertNotSame(androidTestRunConfiguration, jUnitConfiguration);
}
Also used : AndroidTestRunConfiguration(com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration) RunConfiguration(com.intellij.execution.configurations.RunConfiguration)

Example 3 with AndroidTestRunConfiguration

use of com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration 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]);
}
Also used : AndroidTestConsoleProperties(com.android.tools.idea.testartifacts.instrumented.AndroidTestConsoleProperties) DefaultRunExecutor(com.intellij.execution.executors.DefaultRunExecutor) Executor(com.intellij.execution.Executor) AndroidTestRunConfiguration(com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) PsiClass(com.intellij.psi.PsiClass) AndroidJUnitConfiguration(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration) SMTRunnerConsoleProperties(com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties)

Example 4 with AndroidTestRunConfiguration

use of com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration 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;
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) AndroidTestRunConfiguration(com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) AndroidTestRunConfiguration(com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration) AndroidJUnitConfiguration(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

AndroidTestRunConfiguration (com.android.tools.idea.testartifacts.instrumented.AndroidTestRunConfiguration)4 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 AndroidJUnitConfiguration (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfiguration)2 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2 AndroidTestConsoleProperties (com.android.tools.idea.testartifacts.instrumented.AndroidTestConsoleProperties)1 Executor (com.intellij.execution.Executor)1 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)1 RunConfigurationBase (com.intellij.execution.configurations.RunConfigurationBase)1 RunProfile (com.intellij.execution.configurations.RunProfile)1 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)1 ProcessHandler (com.intellij.execution.process.ProcessHandler)1 SMTRunnerConsoleProperties (com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties)1 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)1 PsiClass (com.intellij.psi.PsiClass)1 Nullable (org.jetbrains.annotations.Nullable)1