You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2021/06/28 14:34:27 UTC

[GitHub] [maven-surefire] kishoretak commented on pull request #252: [SUREFIRE-1711] Support @ParameterizedTest for JUnit 5 test reruns

kishoretak commented on pull request #252:
URL: https://github.com/apache/maven-surefire/pull/252#issuecomment-869738348


   @Tibor17 When using "surefire-junit-platform" as the provider, selecting a single parametrized test (junit4) doesn't work as mentioned here- http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#test
   The same works fine with "surefire-junit47" provider, so one way to handle that is to add both the provider.
   Using mvn test -Dtest=sampletests.JUnit4ParametrizedExampleTest#sampleTest[true] for below example works.
   
   `package sampletests;
   
   import org.junit.Test;
   import org.junit.runner.RunWith;
   import org.junit.runners.Parameterized;
   
   import java.util.Arrays;
   import java.util.Collection;
   
   @RunWith(Parameterized.class)
   public class JUnit4ParametrizedExampleTest {
   
       final boolean b;
   
       @Parameterized.Parameters(name="{0}")
       public static Collection<Object[]> data() {
           return Arrays.asList(new Object[][]{
                   {false},
                   {true}
           });
       }
   
       public JUnit4ParametrizedExampleTest(boolean b) {
           this.b = b;
       }
   
       @Test
       public void sampleTest() {
           /* always succeed */
       }
   }`
   
   ===================================
   
   But for the junit5 parameterized test I couldn't run a single Parameterised with any of the below options, any idea what I'm doing wrong here?
   
   mvn test -Dtest=sampletests.JUnit4ParametrizedExampleTest#sampleTest[true]
   mvn test -Dtest=sampletests.JUnit4ParametrizedExampleTest#sampleTest[1]
   
   `package sampletests;
   
   import org.junit.jupiter.params.ParameterizedTest;
   import org.junit.jupiter.params.provider.ValueSource;
   
   public class JUnit5ParametrizedExampleTest {
       @ParameterizedTest
       @ValueSource(booleans={true,false})
       void sampleTest(boolean b) {
       }
   }
   `
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org