Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify which @Tag should be used for JUnit in IntelliJ IDEA

Is there a way to specify from the build in JUnit5 Runner of IntelliJ that only test methods with specific @Tag should be tested (or the opposite, that all tests except those with a specific @Tag, should be executed)?

I know how to do it with maven, but is it possible with just the IntelliJ UI?

Best regards, Dieter

like image 306
Dieter Avatar asked May 31 '17 20:05

Dieter


People also ask

How do I change JUnit 4 to JUnit 5 in Intellij?

Press ⌥⏎, or Alt+Enter, in the class name and IntelliJ IDEA offers to migrate the test class to JUnit 5. The refactoring preview window will show the places where changes will be made, in this case a number of annotations will be changed to the new JUnit 5 annotations.


2 Answers

Now it is possible with Intellij IDEA 2018.1:

enter image description here

See Tag Expressions to select which tests to execute according with their tagging.


Also, you can take a look at this answer for details on how to achieve the same goal using maven-surefire-plugin.

like image 102
lcnicolau Avatar answered Oct 02 '22 20:10

lcnicolau


With https://youtrack.jetbrains.com/issue/IDEA-163481 fixed, it is now possible since IJ 2018.1 -- for details see @Nicolau 's answer.

like image 30
Sormuras Avatar answered Oct 02 '22 18:10

Sormuras