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

Introduce IterationSelector #2743

Merged
merged 10 commits into from
Nov 2, 2021
Merged

Introduce IterationSelector #2743

merged 10 commits into from
Nov 2, 2021

Conversation

marcphilipp
Copy link
Member

Resolves #2738.

@codecov
Copy link

codecov bot commented Oct 8, 2021

Codecov Report

Merging #2743 (ca5b9ea) into main (74a6b4e) will decrease coverage by 0.08%.
The diff coverage is 78.46%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #2743      +/-   ##
============================================
- Coverage     91.11%   91.02%   -0.09%     
- Complexity     4439     4460      +21     
============================================
  Files           383      384       +1     
  Lines         10747    10799      +52     
  Branches        834      840       +6     
============================================
+ Hits           9792     9830      +38     
- Misses          739      746       +7     
- Partials        216      223       +7     
Impacted Files Coverage Δ
...org/junit/platform/commons/util/Preconditions.java 91.66% <50.00%> (-2.46%) ⬇️
...t/platform/engine/discovery/IterationSelector.java 55.00% <55.00%> (ø)
...piter/engine/discovery/MethodSelectorResolver.java 96.47% <78.57%> (-3.53%) ⬇️
...ter/engine/descriptor/DynamicDescendantFilter.java 92.30% <94.44%> (ø)
...r/engine/descriptor/TestFactoryTestDescriptor.java 92.30% <100.00%> (+0.24%) ⬆️
.../engine/descriptor/TestTemplateTestDescriptor.java 100.00% <100.00%> (ø)
.../platform/engine/discovery/DiscoverySelectors.java 90.09% <100.00%> (+0.30%) ⬆️
...rt/discovery/EngineDiscoveryRequestResolution.java 82.45% <100.00%> (+0.31%) ⬆️
...orm/engine/support/discovery/SelectorResolver.java 88.63% <100.00%> (+0.26%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 74a6b4e...ca5b9ea. Read the comment docs.

@marcphilipp
Copy link
Member Author

Related Spock PR: spockframework/spock#1379

Copy link
Member Author

@marcphilipp marcphilipp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Also add support for ConsoleLauncher.

@marcphilipp marcphilipp force-pushed the marc/iteration-selectors branch 2 times, most recently from 032e0e9 to 14a9ff9 Compare October 31, 2021 14:59
@marcphilipp marcphilipp marked this pull request as ready for review October 31, 2021 15:11
@marcphilipp marcphilipp requested review from leonard84 and a team October 31, 2021 15:11
@marcphilipp
Copy link
Member Author

marcphilipp commented Oct 31, 2021

I added support to select iterations via ConsoleLauncher:

$ gw :documentation:consoleLauncher --args="--select-iteration=method:example.ParameterizedTestDemo#palindromes(java.lang.String)[0,2]"
Using gradle at '/Users/marc/Repositories/junit5/gradlew' to run buildfile '/Users/marc/Repositories/junit5/build.gradle.kts':

Type-safe dependency accessors is an incubating feature.
Type-safe project accessors is an incubating feature.

> Task :documentation:consoleLauncher

Thanks for using JUnit! Support its development at https://junit.org/sponsoring


├─ JUnit Vintage ✔
├─ JUnit Platform Suite ✔
└─ JUnit Jupiter ✔
   └─ ParameterizedTestDemo ✔
      └─ palindromes(String) ✔
         ├─ [1] candidate=racecar ✔
         └─ [3] candidate=able was I ere I saw elba ✔

Test run finished after 131 ms
[         5 containers found      ]
[         0 containers skipped    ]
[         5 containers started    ]
[         0 containers aborted    ]
[         5 containers successful ]
[         0 containers failed     ]
[         2 tests found           ]
[         0 tests skipped         ]
[         2 tests started         ]
[         0 tests aborted         ]
[         2 tests successful      ]
[         0 tests failed          ]


BUILD SUCCESSFUL in 4s
95 actionable tasks: 33 executed, 62 up-to-date

Publishing build scan...
https://ge.junit.org/s/rhvdhs6tzwz7o

@marcphilipp marcphilipp force-pushed the marc/iteration-selectors branch 5 times, most recently from 81c9f69 to 51ca1d6 Compare November 1, 2021 09:22
@marcphilipp marcphilipp force-pushed the marc/iteration-selectors branch from 7d253bf to ca5b9ea Compare November 1, 2021 12:35
@sormuras
Copy link
Member

sormuras commented Nov 2, 2021

Had another brief look at this PR and I like it.

  • What should other (not Jupiter, Vintage, TestNGine) TestEngine implementors add to their engines in order to support this new selector?
  • Is the CLI syntax "just" an extension of the already exsting one? For example, would those work?
    • -select-iteration="method:example.ParameterizedTestDemo#palindromes(java.lang.String)[0,2]"
    • -select-method="example.ParameterizedTestDemo#palindromes(java.lang.String)"

@marcphilipp
Copy link
Member Author

marcphilipp commented Nov 2, 2021

What should other (not Jupiter, Vintage, TestNGine) TestEngine implementors add to their engines in order to support this new selector?

They'd have to check for IterationSelector as another DiscoverySelector if they have a use case where that makes sense (see spockframework/spock#1379 for an example).

Is the CLI syntax "just" an extension of the already exsting one? For example, would those work?

Yes, they would. The syntax is --select-iteration="<TYPE>:<VALUE>[<INDEX>(,<INDEX>)]" where <VALUE> is the string that would normally be passed to --select-<TYPE>.

Copy link
Member

@sormuras sormuras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

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

Successfully merging this pull request may close these issues.

Introduce iterationSelector DiscoverySelector to JUnit Platform
3 participants