Search in sources :

Example 11 with TestContextRunConfigurationProducer

use of com.google.idea.blaze.base.run.producers.TestContextRunConfigurationProducer in project intellij by bazelbuild.

the class MultipleJavaClassesTestContextProviderTest method testNotProducedFromNonTestFiles.

@Test
public void testNotProducedFromNonTestFiles() throws Throwable {
    MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot);
    builder.setTargetMap(TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setKind("java_test").setLabel("//java/com/google/test:allTests").addSource(sourceRoot("java/com/google/test/NonTestClass1.java")).addSource(sourceRoot("java/com/google/test/NonTestClass2.java")).build()).build());
    registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(builder.build()));
    workspace.createPsiDirectory(new WorkspacePath("java/com/google/test"));
    PsiFile testClass1 = createAndIndexFile(new WorkspacePath("java/com/google/test/NonTestClass1.java"), "package com.google.test;", "public class NonTestClass1 {");
    PsiFile testClass2 = createAndIndexFile(new WorkspacePath("java/com/google/test/NonTestClass2.java"), "package com.google.test;", "public class NonTestClass2 {}");
    ConfigurationContext context = createContextFromMultipleElements(new PsiElement[] { testClass1, testClass2 });
    ConfigurationFromContext fromContext = new TestContextRunConfigurationProducer().createConfigurationFromContext(context);
    assertThat(fromContext).isNull();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ConfigurationContext(com.intellij.execution.actions.ConfigurationContext) TestContextRunConfigurationProducer(com.google.idea.blaze.base.run.producers.TestContextRunConfigurationProducer) MockBlazeProjectDataBuilder(com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder) ConfigurationFromContext(com.intellij.execution.actions.ConfigurationFromContext) PsiFile(com.intellij.psi.PsiFile) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) Test(org.junit.Test)

Aggregations

TestContextRunConfigurationProducer (com.google.idea.blaze.base.run.producers.TestContextRunConfigurationProducer)11 ConfigurationContext (com.intellij.execution.actions.ConfigurationContext)11 Test (org.junit.Test)11 BlazeCommandRunConfiguration (com.google.idea.blaze.base.run.BlazeCommandRunConfiguration)9 MockBlazeProjectDataBuilder (com.google.idea.blaze.base.model.MockBlazeProjectDataBuilder)8 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)8 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)8 PsiFile (com.intellij.psi.PsiFile)5 ConfigurationFromContext (com.intellij.execution.actions.ConfigurationFromContext)4 PsiMethod (com.intellij.psi.PsiMethod)3 BlazeCommandRunConfigurationCommonState (com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState)2 PsiDirectory (com.intellij.psi.PsiDirectory)2 ArrayList (java.util.ArrayList)2 PsiJavaFile (com.intellij.psi.PsiJavaFile)1