maven-surefire icon indicating copy to clipboard operation
maven-surefire copied to clipboard

[SUREFIRE-2010] Parameterized Selection Does not Work

Open DaGeRe opened this issue 3 years ago • 7 comments

This pull request provides the example project for an integration test, that checks whether selectors are able to select parameterized tests, e.g. package.TestClazz#method[1], where 1 is the index of the test.

Following this checklist to help us incorporate your contribution quickly and easily:

  • [x] Make sure there is a JIRA issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
  • [x] Each commit in the pull request should have a meaningful subject line and body.
  • [x] Format the pull request title like [SUREFIRE-XXX] - Fixes bug in ApproximateQuantiles, where you replace SUREFIRE-XXX with the appropriate JIRA issue. Best practice is to use the JIRA issue title in the pull request title and in the first line of the commit message.
  • [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • [x] Run mvn clean install to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • [ ] You have run the integration tests successfully (mvn -Prun-its clean install).

To make clear that you license your contribution under the Apache License Version 2.0, January 2004 you have to acknowledge this by using the following check-box.

DaGeRe avatar Feb 24 '22 14:02 DaGeRe

Hi @DaGeRe ,

The JIRA is not well suited to read code patches. We can discuss the code even if the CI would fail.

Tibor17 avatar Feb 24 '22 16:02 Tibor17

@DaGeRe If we want to test our documentation, we should use the pattern which would filter only some executions of parameterized test. Example mvn test -Dtest=*ExampleTestJUnit4#testMethod[5:*] and the IT allows you to assert lines in the logs and XML reports too. https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html

Tibor17 avatar Feb 25 '22 11:02 Tibor17

Thanks for the hints. I adapted the code, but is there any part of the maven launcher which allows to pass something like -Dtest=MySelector, or do I have to call it myself? Just adding it as goal ends in

[ERROR] Unknown lifecycle phase "test -Dtest=ExampleTestJUnit4". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version
>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, g
enerate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-cle
an, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]

I can debug this with -Dmaven.surefire.debug=true, but that does not help to create the process correctly.

DaGeRe avatar Mar 08 '22 16:03 DaGeRe

Thanks for the hints. I adapted the code, but is there any part of the maven launcher which allows to pass something like -Dtest=MySelector, or do I have to call it myself? Just adding it as goal ends in

[ERROR] Unknown lifecycle phase "test -Dtest=ExampleTestJUnit4". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version
>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, g
enerate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-cle
an, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]

I can debug this with -Dmaven.surefire.debug=true, but that does not help to create the process correctly.

Make sure to use org.apache.maven.surefire.its.fixture.SurefireLauncher#sysProp to add the option and not the execute method execute("test -Dtest=...")

chalmagr avatar Jun 06 '22 15:06 chalmagr

The best way to pass something like -Dtest=MySelector to the SurefireLauncher is to use SurefireLauncher#setTestToRun like this:

unpack( "surefire-2010-parameterized-selection-does-not-work" )
    .setTestToRun( "MySelector" )
    .executeTest();

andpab avatar Jan 01 '23 23:01 andpab

Hi all! Any news about this problem?

Is still actual on maven 3.1.2 and Junit 5.10.1

AlexShmydov avatar Apr 25 '24 12:04 AlexShmydov

',~-iç⟩fila=_‘u’_[I,\,ú\_,]”„·ū·”„f–pragnant era)—(it1613/°n-/~nkyun*-08',,-‘,-‘control·,·,cut fish<ifad Arafat>]‹/\›... SCE

Mohammad-gif avatar Apr 26 '24 04:04 Mohammad-gif

Guys, can somebody to help? I am talking about https://github.com/junit-team/junit5/pull/2743 and https://issues.apache.org/jira/browse/SUREFIRE-1724 How we can run single invocation of test?

AlexShmydov avatar Apr 29 '24 13:04 AlexShmydov