junit 5 tags support (IDEA-163481)
authorAnna.Kozlova <anna.kozlova@jetbrains.com>
Thu, 11 Jan 2018 15:44:58 +0000 (16:44 +0100)
committerAnna.Kozlova <anna.kozlova@jetbrains.com>
Thu, 11 Jan 2018 15:49:26 +0000 (16:49 +0100)
plugins/junit/src/com/intellij/execution/junit/JUnitConfiguration.java
plugins/junit/src/com/intellij/execution/junit/TestObject.java
plugins/junit/src/com/intellij/execution/junit/TestTags.java [new file with mode: 0644]
plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurable.form
plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurable.java
plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurationModel.java
plugins/junit5_rt/src/com/intellij/junit5/JUnit5TestRunnerUtil.java

index 18077f8733fe0820e8daaf1b97926d2931b7aa25..5d0c849d4d286957d88aa01b274af87d0e5e36f3 100644 (file)
@@ -50,6 +50,7 @@ public class JUnitConfiguration extends JavaTestConfigurationBase {
   @NonNls public static final String TEST_CATEGORY = "category";
   @NonNls public static final String TEST_METHOD = "method";
   @NonNls public static final String TEST_UNIQUE_ID = "uniqueId";
+  @NonNls public static final String TEST_TAGS = "tags";
   @NonNls public static final String BY_SOURCE_POSITION = "source location";
   @NonNls public static final String BY_SOURCE_CHANGES = "changes";
 
@@ -536,6 +537,7 @@ public class JUnitConfiguration extends JavaTestConfigurationBase {
     public String MAIN_CLASS_NAME;
     public String METHOD_NAME;
     private String[] UNIQUE_ID;
+    private String[] TAGS;
     public String TEST_OBJECT = TEST_CLASS;
     public String VM_PARAMETERS;
     public String PARAMETERS;
@@ -566,6 +568,7 @@ public class JUnitConfiguration extends JavaTestConfigurationBase {
              Comparing.equal(DIR_NAME, second.DIR_NAME) &&
              Comparing.equal(CATEGORY_NAME, second.CATEGORY_NAME) &&
              Comparing.equal(UNIQUE_ID, second.UNIQUE_ID) &&
+             Comparing.equal(TAGS, second.TAGS) &&
              Comparing.equal(REPEAT_MODE, second.REPEAT_MODE) &&
              REPEAT_COUNT == second.REPEAT_COUNT;
     }
@@ -583,6 +586,7 @@ public class JUnitConfiguration extends JavaTestConfigurationBase {
              Comparing.hashcode(DIR_NAME) ^
              Comparing.hashcode(CATEGORY_NAME) ^
              Comparing.hashcode(UNIQUE_ID) ^
+             Comparing.hashcode(TAGS) ^
              Comparing.hashcode(REPEAT_MODE) ^
              Comparing.hashcode(REPEAT_COUNT);
     }
@@ -648,6 +652,14 @@ public class JUnitConfiguration extends JavaTestConfigurationBase {
       return setMainClass(methodLocation instanceof MethodLocation ? ((MethodLocation)methodLocation).getContainingClass() : method.getContainingClass());
     }
 
+    public String[] getTags() {
+      return TAGS;
+    }
+
+    public void setTags(String[] tags) {
+      TAGS = tags;
+    }
+
     public static String getMethodPresentation(PsiMethod method) {
       if (method.getParameterList().getParametersCount() > 0 && MetaAnnotationUtil.isMetaAnnotated(method, JUnitUtil.TEST5_ANNOTATIONS)) {
         return method.getName() + "(" + ClassUtil.getVMParametersMethodSignature(method) + ")";
@@ -690,6 +702,9 @@ public class JUnitConfiguration extends JavaTestConfigurationBase {
       if (TEST_UNIQUE_ID.equals(TEST_OBJECT)) {
         return UNIQUE_ID != null ? StringUtil.join(UNIQUE_ID, " ") : "Temp suite";
       }
+      if (TEST_TAGS.equals(TEST_OBJECT)) {
+        return TAGS != null ? "Tags (" + StringUtil.join(TAGS, " ") + ")" : "Temp suite";
+      }
       final String className = JavaExecutionUtil.getPresentableClassName(getMainClassName());
       if (TEST_METHOD.equals(TEST_OBJECT)) {
         return className + '.' + getMethodName();
index cebc83bae4c75e0969b39ea27f59267a1f1accbd..c6bcdbd930272c5a683e83b9e286c78fcfdbb9aa 100644 (file)
@@ -84,38 +84,86 @@ public abstract class TestObject extends JavaTestFrameworkRunnableState<JUnitCon
 
   private final JUnitConfiguration myConfiguration;
   protected File myListenersFile;
-  public static TestObject fromString(final String id,
-                                      final JUnitConfiguration configuration,
-                                      @NotNull ExecutionEnvironment environment) {
-    if (JUnitConfiguration.TEST_METHOD.equals(id)) {
-      return new TestMethod(configuration, environment);
-    }
-    if (JUnitConfiguration.TEST_CLASS.equals(id)) {
-      return new TestClass(configuration, environment);
-    }
-    if (JUnitConfiguration.TEST_PACKAGE.equals(id)){
-      return new TestPackage(configuration, environment);
-    }
-    if (JUnitConfiguration.TEST_DIRECTORY.equals(id)) {
-      return new TestDirectory(configuration, environment);
-    }
-    if (JUnitConfiguration.TEST_CATEGORY.equals(id)) {
-      return new TestCategory(configuration, environment);
-    }
-    if (JUnitConfiguration.TEST_PATTERN.equals(id)) {
-      return new TestsPattern(configuration, environment);
-    }
-    if (JUnitConfiguration.TEST_UNIQUE_ID.equals(id)) {
-      return new TestUniqueId(configuration, environment);
-    }
-    if (JUnitConfiguration.BY_SOURCE_POSITION.equals(id)) {
-      return new TestBySource(configuration, environment);
+  protected <T> void addClassesListToJavaParameters(Collection<? extends T> elements,
+                                                    Function<T, String> nameFunction,
+                                                    String packageName,
+                                                    boolean createTempFile, JavaParameters javaParameters) throws CantRunException {
+    try {
+      if (createTempFile) {
+        createTempFiles(javaParameters);
+      }
+
+      final Map<Module, List<String>> perModule = forkPerModule() ? new TreeMap<>(
+        (o1, o2) -> StringUtil.compare(o1.getName(), o2.getName(), true)) : null;
+
+      final List<String> testNames = new ArrayList<>();
+
+      if (elements.isEmpty() && perModule != null) {
+        final SourceScope sourceScope = getSourceScope();
+        Project project = getConfiguration().getProject();
+        if (sourceScope != null && packageName != null
+            && JUnitStarter.JUNIT5_PARAMETER.equals(getRunner())) {
+          final PsiPackage aPackage = JavaPsiFacade.getInstance(getConfiguration().getProject()).findPackage(packageName);
+          if (aPackage != null) {
+            final TestSearchScope scope = getScope();
+            if (scope != null) {
+              final GlobalSearchScope configurationSearchScope = GlobalSearchScopesCore.projectTestScope(project)
+                .intersectWith(sourceScope.getGlobalSearchScope());
+              final PsiDirectory[] directories = aPackage.getDirectories(configurationSearchScope);
+              for (PsiDirectory directory : directories) {
+                Module module = ModuleUtilCore.findModuleForFile(directory.getVirtualFile(), project);
+                if (module != null) {
+                  perModule.put(module, Collections.emptyList());
+                }
+              }
+            }
+          }
+        }
+      }
+
+      for (final T element : elements) {
+        final String name = nameFunction.fun(element);
+        if (name == null) {
+          continue;
+        }
+
+        final PsiElement psiElement = retrievePsiElement(element);
+        if (perModule != null && psiElement != null) {
+          final Module module = ModuleUtilCore.findModuleForPsiElement(psiElement);
+          if (module != null) {
+            List<String> list = perModule.get(module);
+            if (list == null) {
+              list = new ArrayList<>();
+              perModule.put(module, list);
+            }
+            list.add(name);
+          }
+        }
+        else {
+          testNames.add(name);
+        }
+      }
+      final JUnitConfiguration.Data data = getConfiguration().getPersistentData();
+      if (perModule != null) {
+        for (List<String> perModuleClasses : perModule.values()) {
+          Collections.sort(perModuleClasses);
+          testNames.addAll(perModuleClasses);
+        }
+      }
+      else if (JUnitConfiguration.TEST_PACKAGE.equals(data.TEST_OBJECT)) {
+        Collections.sort(testNames); //sort tests in FQN order
+      }
+
+      final String category = JUnitConfiguration.TEST_CATEGORY.equals(data.TEST_OBJECT) ? data.getCategory()
+                                                                                        : JUnitConfiguration.TEST_TAGS.equals(data.TEST_OBJECT) ? StringUtil.join(data.getTags(), " ") : "";
+      final String filters = JUnitConfiguration.TEST_PATTERN.equals(data.TEST_OBJECT) ? data.getPatternPresentation() : "";
+      JUnitStarter.printClassesList(testNames, packageName, category, filters, myTempFile);
+
+      writeClassesPerModule(packageName, javaParameters, perModule);
     }
-    if (JUnitConfiguration.BY_SOURCE_CHANGES.equals(id)) {
-      return new TestsByChanges(configuration, environment);
+    catch (IOException e) {
+      LOG.error(e);
     }
-    LOG.info(MESSAGE + id);
-    return null;
   }
 
   public Module[] getModulesToCompile() {
@@ -319,85 +367,41 @@ public abstract class TestObject extends JavaTestFrameworkRunnableState<JUnitCon
     return getConfiguration().getForkMode();
   }
 
-  protected <T> void addClassesListToJavaParameters(Collection<? extends T> elements,
-                                                    Function<T, String> nameFunction,
-                                                    String packageName,
-                                                    boolean createTempFile, JavaParameters javaParameters) throws CantRunException {
-    try {
-      if (createTempFile) {
-        createTempFiles(javaParameters);
-      }
-
-      final Map<Module, List<String>> perModule = forkPerModule() ? new TreeMap<>(
-        (o1, o2) -> StringUtil.compare(o1.getName(), o2.getName(), true)) : null;
-
-      final List<String> testNames = new ArrayList<>();
-
-      if (elements.isEmpty() && perModule != null) {
-        final SourceScope sourceScope = getSourceScope();
-        Project project = getConfiguration().getProject();
-        if (sourceScope != null && packageName != null 
-            && JUnitStarter.JUNIT5_PARAMETER.equals(getRunner())) {
-          final PsiPackage aPackage = JavaPsiFacade.getInstance(getConfiguration().getProject()).findPackage(packageName);
-          if (aPackage != null) {
-            final TestSearchScope scope = getScope();
-            if (scope != null) {
-              final GlobalSearchScope configurationSearchScope = GlobalSearchScopesCore.projectTestScope(project)
-                .intersectWith(sourceScope.getGlobalSearchScope());
-              final PsiDirectory[] directories = aPackage.getDirectories(configurationSearchScope);
-              for (PsiDirectory directory : directories) {
-                Module module = ModuleUtilCore.findModuleForFile(directory.getVirtualFile(), project);
-                if (module != null) {
-                  perModule.put(module, Collections.emptyList());
-                }
-              }
-            }
-          }
-        }
-      }
-      
-      for (final T element : elements) {
-        final String name = nameFunction.fun(element);
-        if (name == null) {
-          continue;
-        }
-
-        final PsiElement psiElement = retrievePsiElement(element);
-        if (perModule != null && psiElement != null) {
-          final Module module = ModuleUtilCore.findModuleForPsiElement(psiElement);
-          if (module != null) {
-            List<String> list = perModule.get(module);
-            if (list == null) {
-              list = new ArrayList<>();
-              perModule.put(module, list);
-            }
-            list.add(name);
-          }
-        }
-        else {
-          testNames.add(name);
-        }
-      }
-      final JUnitConfiguration.Data data = getConfiguration().getPersistentData();
-      if (perModule != null) {
-        for (List<String> perModuleClasses : perModule.values()) {
-          Collections.sort(perModuleClasses);
-          testNames.addAll(perModuleClasses);
-        }
-      }
-      else if (JUnitConfiguration.TEST_PACKAGE.equals(data.TEST_OBJECT)) {
-        Collections.sort(testNames); //sort tests in FQN order
-      }
-
-      final String category = JUnitConfiguration.TEST_CATEGORY.equals(data.TEST_OBJECT) ? data.getCategory() : "";
-      final String filters = JUnitConfiguration.TEST_PATTERN.equals(data.TEST_OBJECT) ? data.getPatternPresentation() : "";
-      JUnitStarter.printClassesList(testNames, packageName, category, filters, myTempFile);
-
-      writeClassesPerModule(packageName, javaParameters, perModule);
+  public static TestObject fromString(final String id,
+                                      final JUnitConfiguration configuration,
+                                      @NotNull ExecutionEnvironment environment) {
+    if (JUnitConfiguration.TEST_METHOD.equals(id)) {
+      return new TestMethod(configuration, environment);
     }
-    catch (IOException e) {
-      LOG.error(e);
+    if (JUnitConfiguration.TEST_CLASS.equals(id)) {
+      return new TestClass(configuration, environment);
+    }
+    if (JUnitConfiguration.TEST_PACKAGE.equals(id)){
+      return new TestPackage(configuration, environment);
+    }
+    if (JUnitConfiguration.TEST_DIRECTORY.equals(id)) {
+      return new TestDirectory(configuration, environment);
+    }
+    if (JUnitConfiguration.TEST_CATEGORY.equals(id)) {
+      return new TestCategory(configuration, environment);
+    }
+    if (JUnitConfiguration.TEST_PATTERN.equals(id)) {
+      return new TestsPattern(configuration, environment);
+    }
+    if (JUnitConfiguration.TEST_UNIQUE_ID.equals(id)) {
+      return new TestUniqueId(configuration, environment);
     }
+    if (JUnitConfiguration.TEST_TAGS.equals(id)) {
+      return new TestTags(configuration, environment);
+    }
+    if (JUnitConfiguration.BY_SOURCE_POSITION.equals(id)) {
+      return new TestBySource(configuration, environment);
+    }
+    if (JUnitConfiguration.BY_SOURCE_CHANGES.equals(id)) {
+      return new TestsByChanges(configuration, environment);
+    }
+    LOG.info(MESSAGE + id);
+    return null;
   }
 
   protected PsiElement retrievePsiElement(Object element) {
diff --git a/plugins/junit/src/com/intellij/execution/junit/TestTags.java b/plugins/junit/src/com/intellij/execution/junit/TestTags.java
new file mode 100644 (file)
index 0000000..d1ea4bf
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+ */
+package com.intellij.execution.junit;
+
+import com.intellij.execution.ExecutionException;
+import com.intellij.execution.configurations.JavaParameters;
+import com.intellij.execution.configurations.JavaRunConfigurationModule;
+import com.intellij.execution.configurations.RuntimeConfigurationError;
+import com.intellij.execution.configurations.RuntimeConfigurationException;
+import com.intellij.execution.runners.ExecutionEnvironment;
+import com.intellij.execution.util.JavaParametersUtil;
+import com.intellij.execution.util.ProgramParametersUtil;
+import com.intellij.psi.*;
+import com.intellij.refactoring.listeners.RefactoringElementListener;
+
+import java.util.Collections;
+
+class TestTags extends TestObject {
+  public TestTags(JUnitConfiguration configuration, ExecutionEnvironment environment) {
+    super(configuration, environment);
+  }
+
+
+  @Override
+  public void checkConfiguration() throws RuntimeConfigurationException {
+    JavaParametersUtil.checkAlternativeJRE(getConfiguration());
+    ProgramParametersUtil.checkWorkingDirectoryExist(
+      getConfiguration(), getConfiguration().getProject(), getConfiguration().getConfigurationModule().getModule());
+    final String[] tags = getConfiguration().getPersistentData().getTags();
+    if (tags == null || tags.length == 0) {
+      throw new RuntimeConfigurationError("Tags are not specified");
+    }
+    final JavaRunConfigurationModule configurationModule = getConfiguration().getConfigurationModule();
+    if (getSourceScope() == null) {
+      configurationModule.checkForWarning();
+    }
+  }
+
+  @Override
+  public String suggestActionName() {
+    return "Tests of " + getConfiguration().getPersistentData().getCategory();
+  }
+
+  @Override
+  public boolean isConfiguredByElement(JUnitConfiguration configuration,
+                                       PsiClass testClass,
+                                       PsiMethod testMethod,
+                                       PsiPackage testPackage,
+                                       PsiDirectory testDir) {
+    return false;
+  }
+
+  @Override
+  protected JavaParameters createJavaParameters() throws ExecutionException {
+    final JavaParameters javaParameters = super.createJavaParameters();
+    //tags written automatically inside
+    addClassesListToJavaParameters(Collections.emptyList(), s -> "", "", true, javaParameters);
+    return javaParameters;
+  }
+
+  @Override
+  public RefactoringElementListener getListener(final PsiElement element, final JUnitConfiguration configuration) {
+    return null;
+  }
+}
index 5530c48e606da6ef668bdb7b552e58c190551035..fc60b3cc910d10fdebd432df1dec1794bee414a8 100644 (file)
@@ -3,7 +3,7 @@
   <grid id="ece1c" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
     <margin top="0" left="0" bottom="0" right="0"/>
     <constraints>
-      <xy x="28" y="28" width="722" height="636"/>
+      <xy x="28" y="28" width="722" height="654"/>
     </constraints>
     <properties/>
     <border type="none"/>
         </constraints>
         <properties/>
       </component>
-      <grid id="5947e" layout-manager="GridLayoutManager" row-count="9" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+      <grid id="5947e" layout-manager="GridLayoutManager" row-count="10" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
         <margin top="0" left="0" bottom="0" right="0"/>
         <constraints>
           <grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
         <children>
           <component id="b109" class="com.intellij.openapi.ui.LabeledComponent" binding="myMethod" custom-create="true">
             <constraints>
-              <grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+              <grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
             </constraints>
             <properties>
               <enabled value="true"/>
           </component>
           <component id="ac0a6" class="com.intellij.openapi.ui.LabeledComponent" binding="myDir">
             <constraints>
-              <grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+              <grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
             </constraints>
             <properties>
               <componentClass value="com.intellij.openapi.ui.TextFieldWithBrowseButton"/>
           </component>
           <component id="9b01f" class="com.intellij.openapi.ui.LabeledComponent" binding="myChangeListLabeledComponent" default-binding="true">
             <constraints>
-              <grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+              <grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
             </constraints>
             <properties>
               <componentClass value="javax.swing.JComboBox"/>
           <grid id="c9a5f" binding="myScopesPanel" layout-manager="GridLayoutManager" row-count="3" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
             <margin top="0" left="0" bottom="0" right="0"/>
             <constraints>
-              <grid row="8" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+              <grid row="9" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
             </constraints>
             <properties/>
             <border type="none"/>
               </component>
             </children>
           </grid>
+          <component id="ac292" class="com.intellij.openapi.ui.LabeledComponent" binding="myTagsField">
+            <constraints>
+              <grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+            </constraints>
+            <properties>
+              <componentClass value="com.intellij.ui.RawCommandLineEditor"/>
+              <labelLocation value="West"/>
+              <text value="Tags"/>
+            </properties>
+          </component>
         </children>
       </grid>
     </children>
index 2e90fba0ae888274bd2117199643797593be5ad2..f7acd7c57fe4f5d8517d01b89750062f8867f79c 100644 (file)
@@ -115,6 +115,7 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
   private JTextField myRepeatCountField;
   private LabeledComponent<JComboBox<String>> myChangeListLabeledComponent;
   private LabeledComponent<RawCommandLineEditor> myUniqueIdField;
+  private LabeledComponent<RawCommandLineEditor> myTagsField;
   private Project myProject;
   private JComponent anchor;
 
@@ -172,6 +173,7 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
     aModel.addElement(JUnitConfigurationModel.METHOD);
     aModel.addElement(JUnitConfigurationModel.CATEGORY);
     aModel.addElement(JUnitConfigurationModel.UNIQUE_ID);
+    aModel.addElement(JUnitConfigurationModel.TAGS);
     if (Registry.is("testDiscovery.enabled")) {
       aModel.addElement(JUnitConfigurationModel.BY_SOURCE_POSITION);
       aModel.addElement(JUnitConfigurationModel.BY_SOURCE_CHANGES);
@@ -202,6 +204,9 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
           case JUnitConfigurationModel.UNIQUE_ID:
             setText("UniqueId");
             break;
+          case JUnitConfigurationModel.TAGS:
+            setText("Tags (JUnit 5)");
+            break;
           case JUnitConfigurationModel.BY_SOURCE_POSITION:
             setText("Through source location");
             break;
@@ -306,9 +311,10 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
     catch (NumberFormatException e) {
       configuration.setRepeatCount(1);
     }
-    myModel.apply(getModuleSelector().getModule(), configuration);
     configuration.getPersistentData().setUniqueIds(myUniqueIdField.getComponent().getText().split(" "));
+    configuration.getPersistentData().setTags(myTagsField.getComponent().getText().split(" "));
     configuration.getPersistentData().setChangeList((String)myChangeListLabeledComponent.getComponent().getSelectedItem());
+    myModel.apply(getModuleSelector().getModule(), configuration);
     applyHelpersTo(configuration);
     final JUnitConfiguration.Data data = configuration.getPersistentData();
     if (myWholeProjectScope.isSelected()) {
@@ -338,6 +344,10 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
     myChangeListLabeledComponent.getComponent().setSelectedItem(configuration.getPersistentData().getChangeList());
     String[] ids = configuration.getPersistentData().getUniqueIds();
     myUniqueIdField.getComponent().setText(ids != null ? StringUtil.join(ids, " ") : null);
+
+    String[] tags = configuration.getPersistentData().getTags();
+    myTagsField.getComponent().setText(tags != null ? StringUtil.join(tags, " ") : null);
+
     myCommonJavaParameters.reset(configuration);
     getModuleSelector().reset(configuration);
     final TestSearchScope scope = configuration.getPersistentData().getScope();
@@ -369,6 +379,7 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
       myClass.setVisible(false);
       myCategory.setVisible(false);
       myUniqueIdField.setVisible(false);
+      myTagsField.setVisible(false);
       myMethod.setVisible(false);
       myDir.setVisible(false);
       myChangeListLabeledComponent.setVisible(false);
@@ -383,6 +394,7 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
       myClass.setVisible(false);
       myCategory.setVisible(false);
       myUniqueIdField.setVisible(false);
+      myTagsField.setVisible(false);
       myChangeListLabeledComponent.setVisible(false);
       myMethod.setVisible(false);
       myForkCb.setEnabled(true);
@@ -397,6 +409,7 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
       myClass.setVisible(true);
       myCategory.setVisible(false);
       myUniqueIdField.setVisible(false);
+      myTagsField.setVisible(false);
       myChangeListLabeledComponent.setVisible(false);
       myMethod.setVisible(false);
       myForkCb.setEnabled(true);
@@ -411,6 +424,7 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
       myClass.setVisible(true);
       myCategory.setVisible(false);
       myUniqueIdField.setVisible(false);
+      myTagsField.setVisible(false);
       myMethod.setVisible(true);
       myChangeListLabeledComponent.setVisible(false);
       myForkCb.setEnabled(false);
@@ -423,6 +437,7 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
       myClass.setVisible(false);
       myCategory.setVisible(true);
       myUniqueIdField.setVisible(false);
+      myTagsField.setVisible(false);
       myMethod.setVisible(false);
       myChangeListLabeledComponent.setVisible(false);
       myForkCb.setEnabled(true);
@@ -437,6 +452,7 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
       myClass.setVisible(false);
       myCategory.setVisible(false);
       myUniqueIdField.setVisible(false);
+      myTagsField.setVisible(false);
       myMethod.setVisible(false);
       myChangeListLabeledComponent.setVisible(true);
       myForkCb.setEnabled(true);
@@ -451,6 +467,22 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
       myClass.setVisible(false);
       myCategory.setVisible(false);
       myUniqueIdField.setVisible(true);
+      myTagsField.setVisible(false);
+      myMethod.setVisible(false);
+      myChangeListLabeledComponent.setVisible(false);
+      myForkCb.setEnabled(true);
+      myForkCb.setModel(new DefaultComboBoxModel(FORK_MODE_ALL));
+      myForkCb.setSelectedItem(selectedItem);
+    }
+    else if (selectedType == JUnitConfigurationModel.TAGS) {
+      myPackagePanel.setVisible(false);
+      myScopesPanel.setVisible(false);
+      myDir.setVisible(false);
+      myPattern.setVisible(false);
+      myClass.setVisible(false);
+      myCategory.setVisible(false);
+      myUniqueIdField.setVisible(false);
+      myTagsField.setVisible(true);
       myMethod.setVisible(false);
       myChangeListLabeledComponent.setVisible(false);
       myForkCb.setEnabled(true);
@@ -465,6 +497,7 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
       myClass.setVisible(false);
       myCategory.setVisible(false);
       myUniqueIdField.setVisible(false);
+      myTagsField.setVisible(false);
       myMethod.setVisible(true);
       myChangeListLabeledComponent.setVisible(false);
       myForkCb.setEnabled(true);
@@ -577,6 +610,7 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
     myPackage.setAnchor(anchor);
     myCategory.setAnchor(anchor);
     myUniqueIdField.setAnchor(anchor);
+    myTagsField.setAnchor(anchor);
     myChangeListLabeledComponent.setAnchor(anchor);
   }
 
@@ -590,6 +624,7 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
     } else */if (newType != JUnitConfigurationModel.ALL_IN_PACKAGE &&
                  newType != JUnitConfigurationModel.PATTERN &&
                  newType != JUnitConfigurationModel.CATEGORY &&
+                 newType != JUnitConfigurationModel.TAGS &&
                  newType != JUnitConfigurationModel.UNIQUE_ID) {
       myModule.setEnabled(true);
     }
@@ -603,6 +638,7 @@ public class JUnitConfigurable<T extends JUnitConfiguration> extends SettingsEdi
     final boolean allInPackageAllInProject = (selectedItem == JUnitConfigurationModel.ALL_IN_PACKAGE ||
                                               selectedItem == JUnitConfigurationModel.PATTERN ||
                                               selectedItem == JUnitConfigurationModel.CATEGORY ||
+                                              selectedItem == JUnitConfigurationModel.TAGS ||
                                               selectedItem == JUnitConfigurationModel.UNIQUE_ID ) && myWholeProjectScope.isSelected();
     myModule.setEnabled(!allInPackageAllInProject);
     if (allInPackageAllInProject) {
index b07f6e302fcee060e9fd388c45968179cbeec02c..05e6e439459dda200bac00c975138c5aa33210fa 100644 (file)
@@ -44,8 +44,9 @@ public class JUnitConfigurationModel {
   public static final int DIR = 4;
   public static final int CATEGORY = 5;
   public static final int UNIQUE_ID = 6;
-  public static final int BY_SOURCE_POSITION = 7;
-  public static final int BY_SOURCE_CHANGES = 8;
+  public static final int TAGS = 7;
+  public static final int BY_SOURCE_POSITION = 8;
+  public static final int BY_SOURCE_CHANGES = 9;
 
   private static final List<String> ourTestObjects;
 
@@ -57,6 +58,7 @@ public class JUnitConfigurationModel {
                                    JUnitConfiguration.TEST_DIRECTORY,
                                    JUnitConfiguration.TEST_CATEGORY,
                                    JUnitConfiguration.TEST_UNIQUE_ID,
+                                   JUnitConfiguration.TEST_TAGS,
                                    JUnitConfiguration.BY_SOURCE_POSITION,
                                    JUnitConfiguration.BY_SOURCE_CHANGES);
   }
index dbf0e87ee9c803285657874ac72c6d5d01fa86e8..0ef68cfe0856b405a36be341ca4ee62eeddc2237 100644 (file)
@@ -50,7 +50,7 @@ public class JUnit5TestRunnerUtil {
           final String packageName = reader.readLine();
           if (packageName == null) return null;
 
-          String tagName = reader.readLine();
+          String tags = reader.readLine();
           String filters = reader.readLine();
           String line;
 
@@ -68,8 +68,10 @@ public class JUnit5TestRunnerUtil {
           else {
             builder = builder.selectors(selectors);
           }
-          if (tagName != null && !tagName.isEmpty()) {
-            builder = builder.filters(TagFilter.includeTags(tagName));
+          if (tags != null && !tags.isEmpty()) {
+            builder = builder
+              .filters(TagFilter.includeTags(tags.split(" ")))
+              .filters(ClassNameFilter.excludeClassNamePatterns("com\\.intellij\\.rt.*"));
           }
           return builder.build();
         }