Search in sources :

Example 1 with JUnitConfigurationType

use of com.intellij.execution.junit.JUnitConfigurationType in project intellij-community by JetBrains.

the class ConfigurationRefactoringsTest method testRenameBadTestClass.

public void testRenameBadTestClass() throws IOException {
    PsiClass psiClass = mySource.createClass("NotATest", NOT_A_TEST);
    assertNotNull(psiClass);
    JUnitConfigurationType instance = JUnitConfigurationType.getInstance();
    assertNotNull(instance);
    JUnitConfiguration configuration = new JUnitConfiguration("notATest", myProject, instance.getConfigurationFactories()[0]);
    configuration.setMainClass(psiClass);
    configuration.setModule(configuration.getValidModules().iterator().next());
    checkConfigurationException("NotATest isn't test class", configuration);
    RunManagerEx.getInstanceEx(myProject).setTemporaryConfiguration(new RunnerAndConfigurationSettingsImpl(null, configuration, false));
    rename(psiClass, "NotATest2");
    JUnitConfiguration.Data data = configuration.getPersistentData();
    assertEquals("NotATest2", data.getMainClassName());
    data.METHOD_NAME = "test";
    data.TEST_OBJECT = JUnitConfiguration.TEST_METHOD;
    checkConfigurationException("Test method 'test' doesn't exist", configuration);
    rename(psiClass.findMethodsByName("test", false)[0], "test2");
    assertEquals("NotATest2", data.getMainClassName());
    assertEquals("test2", data.getMethodName());
}
Also used : JUnitConfiguration(com.intellij.execution.junit.JUnitConfiguration) RunnerAndConfigurationSettingsImpl(com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl) JUnitConfigurationType(com.intellij.execution.junit.JUnitConfigurationType)

Example 2 with JUnitConfigurationType

use of com.intellij.execution.junit.JUnitConfigurationType in project android by JetBrains.

the class AndroidStudioInitializer method disableIdeaJUnitConfigurations.

// JUnit original Extension JUnitConfigurationType is disabled so it can be replaced by its child class AndroidJUnitConfigurationType
private static void disableIdeaJUnitConfigurations() {
    // First we unregister the ConfigurationProducers, and after the ConfigurationType
    ExtensionPoint<RunConfigurationProducer> configurationProducerExtensionPoint = Extensions.getRootArea().getExtensionPoint(RunConfigurationProducer.EP_NAME);
    for (RunConfigurationProducer runConfigurationProducer : configurationProducerExtensionPoint.getExtensions()) {
        if (runConfigurationProducer instanceof JUnitConfigurationProducer && !(runConfigurationProducer instanceof AndroidJUnitConfigurationProducer)) {
            // In AndroidStudio these ConfigurationProducer s are replaced
            configurationProducerExtensionPoint.unregisterExtension(runConfigurationProducer);
        }
    }
    ExtensionPoint<ConfigurationType> configurationTypeExtensionPoint = Extensions.getRootArea().getExtensionPoint(ConfigurationType.CONFIGURATION_TYPE_EP);
    for (ConfigurationType configurationType : configurationTypeExtensionPoint.getExtensions()) {
        if (configurationType instanceof JUnitConfigurationType && !(configurationType instanceof AndroidJUnitConfigurationType)) {
            // In Android Studio the user is forced to use AndroidJUnitConfigurationType instead of JUnitConfigurationType
            configurationTypeExtensionPoint.unregisterExtension(configurationType);
        }
    }
    // We hide actions registered by the JUnit plugin and instead we use those registered in android-junit.xml
    hideAction("excludeFromSuite");
    hideAction("AddToISuite");
}
Also used : ConfigurationType(com.intellij.execution.configurations.ConfigurationType) AndroidJUnitConfigurationType(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType) JUnitConfigurationType(com.intellij.execution.junit.JUnitConfigurationType) RunConfigurationProducer(com.intellij.execution.actions.RunConfigurationProducer) AndroidJUnitConfigurationType(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType) AndroidJUnitConfigurationProducer(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationProducer) AndroidJUnitConfigurationType(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType) JUnitConfigurationType(com.intellij.execution.junit.JUnitConfigurationType) JUnitConfigurationProducer(com.intellij.execution.junit.JUnitConfigurationProducer) AndroidJUnitConfigurationProducer(com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationProducer)

Example 3 with JUnitConfigurationType

use of com.intellij.execution.junit.JUnitConfigurationType in project android by JetBrains.

the class AndroidJUnitConfigurationTypeTest method testJUnitConfigurationTypeGetInstance.

// Since JUnitConfigurationType is disabled in AndroidStudioInitializer, and AndroidJUnitConfigurationType
// is registered as child, it should be returned when getInstance() of the parent is called
public void testJUnitConfigurationTypeGetInstance() {
    JUnitConfigurationType configurationType = JUnitConfigurationType.getInstance();
    assertInstanceOf(configurationType, AndroidJUnitConfigurationType.class);
}
Also used : JUnitConfigurationType(com.intellij.execution.junit.JUnitConfigurationType)

Aggregations

JUnitConfigurationType (com.intellij.execution.junit.JUnitConfigurationType)3 AndroidJUnitConfigurationProducer (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationProducer)1 AndroidJUnitConfigurationType (com.android.tools.idea.testartifacts.junit.AndroidJUnitConfigurationType)1 RunConfigurationProducer (com.intellij.execution.actions.RunConfigurationProducer)1 ConfigurationType (com.intellij.execution.configurations.ConfigurationType)1 RunnerAndConfigurationSettingsImpl (com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl)1 JUnitConfiguration (com.intellij.execution.junit.JUnitConfiguration)1 JUnitConfigurationProducer (com.intellij.execution.junit.JUnitConfigurationProducer)1