[ 
https://issues.apache.org/jira/browse/SUREFIRE-2010?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17497354#comment-17497354
 ] 

David Georg Reichelt commented on SUREFIRE-2010:
------------------------------------------------

Unfortunately, I did not succeed to write a working integration test.

I looked at 
[https://maven.apache.org/surefire/maven-surefire-plugin/developing.html,] 
which stated that I should to
{code:java}
cd surefire-integration-tests/src/test/resources/failsafe-buildfail
mvn -Dsurefire.version=2.12 verify {code}
This did not work (and the link provided there is also not working), since the 
folder now seems to be named
{code:java}
surefire-its 
{code}
Could you fix this, or should I just change 
[https://github.com/apache/maven-surefire/blob/master/maven-surefire-plugin/src/site/apt/developing.apt.vm]
 and create a PR?

Doing
{code:java}
surefire-its/src/test/resources/surefire-1146-rerunFailingTests-with-Parameterized
mvn -Dsurefire.version=3.0.0-M6-SNAPSHOT verify
{code}
works fine for me and yields the output I would expect.

Now I would like to write the integration test itself. After some fiddeling, I 
got the old test running by
{code:java}
mvn verify -Dsurefire.version=3.0.0-M6-SNAPSHOT 
-Dtest=Surefire1146RerunFailedAndParameterizedIT
{code}
Unfortunately, for my new test 
[https://github.com/DaGeRe/maven-surefire/blob/surefire-2010/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2010ParameterizedSelectionDoesNotWorkIT.java]
 (that currently does not select anything and should just execute the tests), 
the output of
{code:java}
mvn verify -Dsurefire.version=3.0.0-M6-SNAPSHOT  
-Dtest=Surefire2010ParameterizedSelectionDoesNotWorkIT
{code}
is
{code:java}
[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile 
(default-testCompile) on project jiras-surefire-2010: Compilation failure       
           
[ERROR] 
/tmp/Surefire2010ParameterizedSelectionDoesNotWorkIT_testJUnit4/src/test/java/junitplatform/ParametersTest.java:[37,22]
 static interface method invocations are not supported in 
-source 7                                                                       
                                                                                
                         
[ERROR]   (use -source 8 or higher to enable static interface method 
invocations)                                                                    
                                    
[ERROR] -> [Help 1]                                                             
                                                                                
                         
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal 
org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile 
(default-testCompile) on project jiras-sure
fire-2010: Compilation failure                                                  
                                                                                
                         
/tmp/Surefire2010ParameterizedSelectionDoesNotWorkIT_testJUnit4/src/test/java/junitplatform/ParametersTest.java:[37,22]
 static interface method invocations are not supported in -source 7 
{code}
I tried to fix this by adding
{code:java}
<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
{code}
to the
{code:java}
surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/pom.xml
{code}
but then I got the following output:
{code:java}
[ERROR] 
junitplatform.ParametersTest.testOneFailingPassingTest(ConnectionPoolFactory)[2]
  Time elapsed: 0.005 s  <<< FAILURE!                                           
                 
org.opentest4j.AssertionFailedError: expected: <1> but was: <2>                 
                                                                                
                         
        at 
junitplatform.ParametersTest.testOneFailingPassingTest(ParametersTest.java:57)  
                                                                                
              
[INFO] Running junitplatform.FlakyFirstTimeTest                                 
                                                                                
                         
Failing test                                                                    
                                                                                
                         
Error test                                                                      
                                                                                
                         
Passing test                                                                    
                                                                                
                         
[ERROR] Tests run: 3, Failures: 1, Errors: 1, Skipped: 0, Time elapsed: 0.004 s 
<<< FAILURE! - in junitplatform.FlakyFirstTimeTest
[ERROR] junitplatform.FlakyFirstTimeTest.testFailingTestOne  Time elapsed: 
0.001 s  <<< FAILURE!                                        
org.opentest4j.AssertionFailedError: Failing test                               
                                                                                
                         
        at 
junitplatform.FlakyFirstTimeTest.testFailingTestOne(FlakyFirstTimeTest.java:42) 
                                                                                
              
[ERROR] junitplatform.FlakyFirstTimeTest.testErrorTestOne  Time elapsed: 0.001 
s  <<< ERROR!                                                                   
                          
java.lang.IllegalArgumentException: ...                                         
                                                                                
                         
        at 
junitplatform.FlakyFirstTimeTest.testErrorTestOne(FlakyFirstTimeTest.java:54)   
                                                                                
              
[INFO] Running junitplatform.PassingTest                                        
                                                                                
                         
Passing test one                                                                
                                                                                
                         
Passing test two                                                                
                                                                                
                         
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s 
- in junitplatform.PassingTest
{code}
Could you give me a hint why this happens / how to solely call my parameterized 
example tests?

> Parameterized Selection Does not Work
> -------------------------------------
>
>                 Key: SUREFIRE-2010
>                 URL: https://issues.apache.org/jira/browse/SUREFIRE-2010
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: Junit 4.x support, JUnit 5.x support
>    Affects Versions: 3.0.0-M5
>         Environment: Maven 3.6.3 and Ubuntu 20.04, but I suppose it happens 
> everywhere
>            Reporter: David Georg Reichelt
>            Priority: Major
>
> In the current version (and also M6-SNAPSHOT), maven surefire is not capable 
> of selecting parameterized tests based on the index. In 
> [https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html,]
>  it is described that this should work by providing the index, e.g. using 
> {code:java}
> -Dtest=MyTest#method[$INDEX]{code}
>  or 
> {code:java}
> -Dtest=MyTest#method[*]{code}
>  for all.
>  
> This happens both for JUnit 4 and JUnit 5.
> I created a mwe demonstrating this problem: 
> [https://github.com/DaGeRe/parameterized-selection-demo]
> As far as I see it, the TestMethodFilter in  
> [https://github.com/apache/maven-surefire/blob/master/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/TestMethodFilter.java#L45]
>  does the filtering, but has only a descriptor in the form:
>  
> {code:java}
> [engine:junit-jupiter]/[class:de.dagere.peass.ExampleTest]/[test-template:test(int)]{code}
>  
> So there is not the concrete value, but only the information that an int 
> should be provided. Therefore, I currently see not any option to fix this 
> easily or get this running using a regex pattern.
> Do I oversee something, or is it planned to fix this? If not, it would be 
> better to update the documentation site accordingly.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to