Search in sources :

Example 11 with ConfigurationContext

use of com.intellij.execution.actions.ConfigurationContext in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoTestRunConfigurationProducerTest method testSameConfigurationOnPackageClause.

public void testSameConfigurationOnPackageClause() {
    PsiFile file = myFixture.addFileToProject("import/path/a_test.go", "packag<caret>e main; func SomeNonTestName() {}");
    myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
    ConfigurationContext configurationContext = createConfigurationContext();
    GotestRunConfigurationProducer producer = new GotestRunConfigurationProducer();
    GoTestRunConfiguration runConfiguration = createPackageConfiguration(GotestFramework.INSTANCE, "", "import/path");
    assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createPackageConfiguration(GotestFramework.INSTANCE, "otherPattern", "import/path");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createPackageConfiguration(GobenchFramework.INSTANCE, "", "import/path");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createPackageConfiguration(GotestFramework.INSTANCE, "", "import/path/other");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) PsiFile(com.intellij.psi.PsiFile) GotestRunConfigurationProducer(com.goide.runconfig.testing.frameworks.gotest.GotestRunConfigurationProducer)

Example 12 with ConfigurationContext

use of com.intellij.execution.actions.ConfigurationContext in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoTestRunConfigurationProducerTest method testSameConfigurationOnFile.

public void testSameConfigurationOnFile() {
    PsiFile file = myFixture.configureByText("a_test.go", "package main; <caret>\n\nfunc SomeNonTestName() {}");
    ConfigurationContext configurationContext = createConfigurationContext();
    GotestRunConfigurationProducer producer = new GotestRunConfigurationProducer();
    GoTestRunConfiguration runConfiguration = createFileConfiguration(GotestFramework.INSTANCE, file.getVirtualFile().getPath());
    assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createFileConfiguration(GotestFramework.INSTANCE, file.getVirtualFile().getPath() + "_vl");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createFileConfiguration(GobenchFramework.INSTANCE, file.getVirtualFile().getPath());
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) PsiFile(com.intellij.psi.PsiFile) GotestRunConfigurationProducer(com.goide.runconfig.testing.frameworks.gotest.GotestRunConfigurationProducer)

Example 13 with ConfigurationContext

use of com.intellij.execution.actions.ConfigurationContext in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoTestRunConfigurationProducerTest method testSameConfigurationOnNonTestFunction.

public void testSameConfigurationOnNonTestFunction() {
    PsiFile file = myFixture.addFileToProject("import/path/a_test.go", "package main; func SomeNonTestName() {<caret>}");
    myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
    ConfigurationContext configurationContext = createConfigurationContext();
    GotestRunConfigurationProducer producer = new GotestRunConfigurationProducer();
    GoTestRunConfiguration runConfiguration = createFileConfiguration(GotestFramework.INSTANCE, file.getVirtualFile().getPath());
    assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createFileConfiguration(GotestFramework.INSTANCE, file.getVirtualFile().getPath() + "_vl");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createFileConfiguration(GobenchFramework.INSTANCE, file.getVirtualFile().getPath());
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) PsiFile(com.intellij.psi.PsiFile) GotestRunConfigurationProducer(com.goide.runconfig.testing.frameworks.gotest.GotestRunConfigurationProducer)

Example 14 with ConfigurationContext

use of com.intellij.execution.actions.ConfigurationContext in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoTestRunConfigurationProducerTest method testSameConfigurationOnFunction.

public void testSameConfigurationOnFunction() {
    PsiFile file = myFixture.addFileToProject("import/path/a_test.go", "package main; func TestName() {<caret>}");
    myFixture.configureFromExistingVirtualFile(file.getVirtualFile());
    ConfigurationContext configurationContext = createConfigurationContext();
    RunConfigurationProducer<GoTestRunConfiguration> producer = new GotestRunConfigurationProducer();
    GoTestRunConfiguration runConfiguration = createPackageConfiguration(GotestFramework.INSTANCE, "^TestName$", "import/path");
    assertTrue(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createPackageConfiguration(GotestFramework.INSTANCE, "otherPattern", "import/path");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createPackageConfiguration(GobenchFramework.INSTANCE, "^TestName$", "import/path");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    runConfiguration = createPackageConfiguration(GotestFramework.INSTANCE, "^TestName$", "import/path/other");
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
    producer = new GobenchRunConfigurationProducer();
    runConfiguration = createFileConfiguration(GobenchFramework.INSTANCE, file.getVirtualFile().getPath());
    assertFalse(producer.isConfigurationFromContext(runConfiguration, configurationContext));
}
Also used : GobenchRunConfigurationProducer(com.goide.runconfig.testing.frameworks.gobench.GobenchRunConfigurationProducer) ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) PsiFile(com.intellij.psi.PsiFile) GotestRunConfigurationProducer(com.goide.runconfig.testing.frameworks.gotest.GotestRunConfigurationProducer)

Example 15 with ConfigurationContext

use of com.intellij.execution.actions.ConfigurationContext in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoTestRunConfigurationProducerTest method createConfigurationContext.

@NotNull
private ConfigurationContext createConfigurationContext() {
    PsiElement at = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    assertNotNull(at);
    return new ConfigurationContext(at);
}
Also used : ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)26 PsiFile (com.intellij.psi.PsiFile)9 PsiElement (com.intellij.psi.PsiElement)7 GotestRunConfigurationProducer (com.goide.runconfig.testing.frameworks.gotest.GotestRunConfigurationProducer)5 ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)5 InheritorChooser (com.intellij.execution.junit.InheritorChooser)5 List (java.util.List)5 RunConfigurationProducer (com.intellij.execution.actions.RunConfigurationProducer)4 Project (com.intellij.openapi.project.Project)4 Location (com.intellij.execution.Location)3 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)3 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)3 MethodLocation (com.intellij.execution.junit2.info.MethodLocation)3 ExternalSystemRunConfiguration (com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration)3 PsiClass (com.intellij.psi.PsiClass)3 PsiMethod (com.intellij.psi.PsiMethod)3 GoApplicationConfiguration (com.goide.runconfig.application.GoApplicationConfiguration)2 GoApplicationRunConfigurationProducer (com.goide.runconfig.application.GoApplicationRunConfigurationProducer)2 GoRunFileConfiguration (com.goide.runconfig.file.GoRunFileConfiguration)2 GoRunFileConfigurationProducer (com.goide.runconfig.file.GoRunFileConfigurationProducer)2