I have a selenium project in Java using JUnit5. I have some suites and several tests with tags. I want to have a suite that runs all tests with both tags
An example of a suite is:
@SelectClasses(ScreenshotComparisonTests.class)
@IncludeTags({"CC"})
@ExcludeTags({"CASH", "FINANCIAL", "HACCP", "HRM", "INVENTORY", "OPERATIONS", "PURCHASING", "REPORTING"})
@Suite
@SuiteDisplayName("C User Menu Screenshots Comparison Tests")
public class CUserMenuScreenshotComparisonSuite {
}
But instead of listing all of the tags to exclude, I'd rather have something like:
@SelectClasses(ScreenshotComparisonTests.class)
@IncludeTags({"CC" & "USERMENU"})
@Suite
@SuiteDisplayName("C User Menu Screenshots Comparison Tests")
public class CUserMenuScreenshotComparisonSuite {
}
But intellij highlights that & as not allowed here. I have read that this is acceptable here https://junit.org/junit5/docs/current/user-guide/#running-tests-tag-expressions
Tried using:
- @IncludeTags("CC" & "USERMENU")
- @IncludeTags{("CC" & "USERMENU")}
- @IncludeTags{"CC" & "USERMENU"}
- @IncludeTags{("CC" && "USERMENU")}
java: bad operand types for binary operator '&'
first type: java.lang.String
second type: java.lang.String
CodePudding user response:
Instead of
@IncludeTags({"CC" & "USERMENU"})
try
@IncludeTags({"CC&USERMENU"})
CodePudding user response:
Thank you johanneslink! You put me on the right track!
As CC and USERMENU are constant Strings I needed to edit your suggestion slightly and this now works for me:
@IncludeTags({CC "&" USERMENU})
Thanks so much, I have much cleaner Suites now!