Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run only "untagged" tests #1679

Closed
calvertdw opened this issue Nov 14, 2018 · 20 comments · Fixed by #2130
Closed

Run only "untagged" tests #1679

calvertdw opened this issue Nov 14, 2018 · 20 comments · Fixed by #2130

Comments

@calvertdw
Copy link

calvertdw commented Nov 14, 2018

I request the ability to run only "untagged" tests.

Most tests will run with default arguments and should not require @Tag("fast"). Other tests require special needs or take a long time so we tag them (i.e. @Tag("slow")). I would prefer not to require the majority of tests to be tagged at all.

Current workarounds include parsing the code for all declared instances of @Tag("*") or using the Launcher#discover method in the build phase, such that all found tags can be excluded.

Deliverables

  • Provide a keyword (i.e. "all") for the excludeTags property to exclude all tests that are tagged OR some solution providing the equivalent result.
@marcphilipp
Copy link
Member

all won't work because someone might already be using a tag with that name.

We could introduce special tag expressions for "no tags" and "at least one tag", e.g. none() and !none().

@junit-team/junit-lambda WDYT?

@sbrannen
Copy link
Member

sbrannen commented Dec 1, 2018

all won't work because someone might already be using a tag with that name.

I agree that all is not an option.

We could introduce special tag expressions for "no tags" and "at least one tag", e.g. none() and !none().

I had a similar idea: great minds think alike. 😉

How about tagged() and !tagged()?

@sbrannen
Copy link
Member

sbrannen commented Dec 1, 2018

Though in terms of the tag expression parsing, it might be better to avoid the use of parentheses.

So perhaps something like $tagged and !$tagged?

We'd just need to make sure we pick special characters that were not previously valid (i.e., perhaps already used by somebody).

Disclaimer: I haven't looked at the exact syntax parsing recently. So the above suggestion may potentially be bogus. 😇

@marcphilipp
Copy link
Member

If I'm not mistaken, $tagged would currently be considered a valid tag (expression). I added the parentheses, because none() is currently invalid.

How about none() and any()?

@marcphilipp marcphilipp modified the milestones: 5.x Backlog, 5.4 Backlog Dec 1, 2018
@calvertdw
Copy link
Author

calvertdw commented Dec 20, 2018

As a note, my current workaround is to use the Launcher#discover method as part of my build, such that all found tags can be excluded. Our specific implementation of this can be found here.

@sbrannen
Copy link
Member

If I'm not mistaken, $tagged would currently be considered a valid tag (expression).

Yeah... as I hinted at, my proposal could well have been bogus, and it in fact is.

In hindsight, we really should have been more restrictive with valid characters in tag names (see org.junit.platform.engine.TestTag.RESERVED_CHARACTERS). Oh well... too late now.

I added the parentheses, because none() is currently invalid.

How about none() and any()?

How about none() and all()?

As in...

  • excludeTags( all() )
  • includeTags( none() )

@marcphilipp
Copy link
Member

marcphilipp commented Dec 22, 2018

I think any() would be better because it is a tag expression that matches all tests that have any tag while none() matches tests that have none.

@sbrannen
Copy link
Member

I think any() would be better because it is a tag expression that matches all tests that have any tag while none() matches tests that have none.

OK. I can agree with you on that, when you phrase it like that. 😉

@calvertdw
Copy link
Author

To make it more clear:

any() would match all tests that have at least one tag.
none() would match all tests that have exactly zero tags.

@calvertdw
Copy link
Author

calvertdw commented Nov 5, 2019

Still looking for this! It's nice for running tests locally in IntelliJ w/o Gradle. It'd be snappy to pass a tag expression to run untagged tests.

@marcphilipp marcphilipp modified the milestones: 5.7 Backlog, 5.6 M2 Nov 5, 2019
@marcphilipp
Copy link
Member

Tentatively slated for 5.6 M2 solely for the purpose of team discussion.

@marcphilipp
Copy link
Member

Team Decision: Let's go with any() and none().

@calvertdw Would you be interested in submitting a PR?

@signed
Copy link
Contributor

signed commented Nov 7, 2019

Should the special terms play nice with operators or be treated separately?

  • ! none()
  • ! any()
  • none() | somethingelse
  • any() | somethingelse (you could just remove something else)
  • any() | none()
  • any() & none()
  • any() & somethingelse (you could just remove any in this case)

Or is only this allowed and the previous examples are all invalid input?

  • none()
  • any()

Treating the 1st sample block as invalid inputs makes the implementation way easier.

@mmerdes
Copy link
Contributor

mmerdes commented Nov 8, 2019

I would favour simplicity over completeness

@marcphilipp
Copy link
Member

If it considerably simplifies the implementation, I'm fine with only supporting none() and any() as standalone expressions for now.

@mmerdes mmerdes self-assigned this Nov 11, 2019
@mmerdes
Copy link
Contributor

mmerdes commented Nov 11, 2019

In progress

@calvertdw
Copy link
Author

calvertdw commented Nov 13, 2019

I think none() | somethingelse would quickly become a useful expression but adding standalone expressions for none() and any() are already a huge improvement. I am fine with either.

Consider the documentation and support in factoring the complexity. Not supporting expressions might be confusing to users.

@calvertdw
Copy link
Author

I see @mmerdes has taken this up, but I might be able to assist given some pointers in the right direction. What classes/interfaces are relevant? In general, what's a good way to do it?

@mmerdes
Copy link
Contributor

mmerdes commented Nov 14, 2019

@calvertdw
Thanks for the offer! I will let you know if I encounter any roadblocks :)

mmerdes added a commit that referenced this issue Dec 17, 2019
mmerdes added a commit that referenced this issue Dec 17, 2019
mmerdes added a commit that referenced this issue Jan 2, 2020
#1679

Co-Authored-By: Marc Philipp <[email protected]>
mmerdes added a commit that referenced this issue Jan 2, 2020
mmerdes added a commit that referenced this issue Jan 2, 2020
#1679

Co-Authored-By: Marc Philipp <[email protected]>
marcphilipp pushed a commit that referenced this issue Jan 3, 2020
Two special expressions, `any()` and `none()`, can now be used in tag
expressions to select all tests _with_ any tags at all, or all tests
_without_ any tags, respectively.

Resolves #1679.
@tcfurrer
Copy link

I just wanna say "Thank You" to everyone who worked on this enhancement. My project's Gradle scripts got simplified significantly when I was finally able to make use of the new any() and none() capability of JUnit 5.6. It's very useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants