From 2ebab658cc2b71bb3bcbd24d2ec70be389dea33e Mon Sep 17 00:00:00 2001 From: David Georg Reichelt Date: Thu, 24 Feb 2022 12:37:31 +0100 Subject: [PATCH 1/3] Started work on parameterized test selector integration test --- ...10ParameterizedSelectionDoesNotWorkIT.java | 36 ++++++++++ .../pom.xml | 65 +++++++++++++++++++ .../de/dagere/peass/ExampleTestJUnit4.java | 36 ++++++++++ .../de/dagere/peass/ExampleTestJUnit5.java | 20 ++++++ 4 files changed, 157 insertions(+) create mode 100644 surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2010ParameterizedSelectionDoesNotWorkIT.java create mode 100644 surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/pom.xml create mode 100644 surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit4.java create mode 100644 surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit5.java diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2010ParameterizedSelectionDoesNotWorkIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2010ParameterizedSelectionDoesNotWorkIT.java new file mode 100644 index 0000000000..fedde0a2ca --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2010ParameterizedSelectionDoesNotWorkIT.java @@ -0,0 +1,36 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.OutputValidator; +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.junit.Test; + +public class Surefire2010ParameterizedSelectionDoesNotWorkIT extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void testJUnit4() { + OutputValidator validator = unpack("surefire-2010-parameterized-selection-does-not-work").executeTest(); + } + + public void testJUnit5() { + + } +} diff --git a/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/pom.xml b/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/pom.xml new file mode 100644 index 0000000000..d3ab0ab9fd --- /dev/null +++ b/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.maven.surefire + it-parent + 1.0 + ../pom.xml + + org.apache.maven.plugins.surefire + jiras-surefire-2010 + 1.0 + http://maven.apache.org + + + DaGeRe + David Georg Reichelt (DaGeRe) + david_georg.reichelt@uni-leipzig.de + + Committer + + Europe/Berlin + + + + + junit + junit + 4.13.2 + test + + + org.junit.jupiter + junit-jupiter-params + 5.8.2 + test + + + + + + maven-surefire-plugin + + + + diff --git a/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit4.java b/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit4.java new file mode 100644 index 0000000000..c0f911f2cb --- /dev/null +++ b/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit4.java @@ -0,0 +1,36 @@ +package de.dagere.peass; + +import java.util.Arrays; +import java.util.Collection; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +@RunWith(Parameterized.class) +public class ExampleTestJUnit4 { + + @Parameters + public static Collection data() { + return Arrays.asList(new Object[][] { + { 0 }, { 1 } + }); + } + + int value; + + public ExampleTestJUnit4(int value) { + this.value = value; + } + + @Test + public void test() { + System.out.println(value); + } + + @Test + public void anotherTest() { + System.out.println("3 (and value ignored)"); + } +} diff --git a/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit5.java b/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit5.java new file mode 100644 index 0000000000..89dbe21946 --- /dev/null +++ b/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit5.java @@ -0,0 +1,20 @@ +package de.dagere.peass; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +public class ExampleTestJUnit5 { + + @ParameterizedTest + @ValueSource(ints = { 0, 1 }) + public void test(final int value) { + System.out.println(value); + } + + @Test + public void anotherTest() { + System.out.println("3"); + } + +} \ No newline at end of file From f49bb63d309c549954464ee647b0da5dc9de81bb Mon Sep 17 00:00:00 2001 From: David Georg Reichelt Date: Thu, 24 Feb 2022 15:24:13 +0100 Subject: [PATCH 2/3] Fix checkstyle problems --- ...efire2010ParameterizedSelectionDoesNotWorkIT.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2010ParameterizedSelectionDoesNotWorkIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2010ParameterizedSelectionDoesNotWorkIT.java index fedde0a2ca..d4ec41aba3 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2010ParameterizedSelectionDoesNotWorkIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2010ParameterizedSelectionDoesNotWorkIT.java @@ -22,15 +22,19 @@ import org.apache.maven.surefire.its.fixture.OutputValidator; import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; import org.junit.Test; - +/** + * @see SUREFIRE-2010 + */ public class Surefire2010ParameterizedSelectionDoesNotWorkIT extends SurefireJUnit4IntegrationTestCase { @Test - public void testJUnit4() { - OutputValidator validator = unpack("surefire-2010-parameterized-selection-does-not-work").executeTest(); + public void testJUnit4() + { + OutputValidator validator = unpack( "surefire-2010-parameterized-selection-does-not-work" ).executeTest(); } - public void testJUnit5() { + public void testJUnit5() + { } } From 3cac9e06be661e1772fd6c359278196a73795b2b Mon Sep 17 00:00:00 2001 From: David Georg Reichelt Date: Tue, 8 Mar 2022 17:25:11 +0100 Subject: [PATCH 3/3] Adapt forking, formatting and test result checking --- ...10ParameterizedSelectionDoesNotWorkIT.java | 27 ++++++---- .../pom.xml | 3 ++ .../de/dagere/peass/ExampleTestJUnit4.java | 53 ++++++++++--------- .../de/dagere/peass/ExampleTestJUnit5.java | 23 ++++---- 4 files changed, 60 insertions(+), 46 deletions(-) diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2010ParameterizedSelectionDoesNotWorkIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2010ParameterizedSelectionDoesNotWorkIT.java index d4ec41aba3..173b0d5cb5 100644 --- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2010ParameterizedSelectionDoesNotWorkIT.java +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire2010ParameterizedSelectionDoesNotWorkIT.java @@ -21,20 +21,25 @@ import org.apache.maven.surefire.its.fixture.OutputValidator; import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.TestFile; import org.junit.Test; + /** * @see SUREFIRE-2010 */ -public class Surefire2010ParameterizedSelectionDoesNotWorkIT extends SurefireJUnit4IntegrationTestCase +public class Surefire2010ParameterizedSelectionDoesNotWorkIT + extends SurefireJUnit4IntegrationTestCase { - @Test - public void testJUnit4() - { - OutputValidator validator = unpack( "surefire-2010-parameterized-selection-does-not-work" ).executeTest(); - } - - public void testJUnit5() - { - - } + @Test + public void testJUnit4() + { + OutputValidator validator = unpack( "surefire-2010-parameterized-selection-does-not-work" ).executeTest(); + TestFile surefireReportsFile = validator.getSurefireReportsFile( "de.dagere.peass.ExampleTestJUnit4.txt" ); + surefireReportsFile.assertContainsText( "Tests run: 2" ); + } + + public void testJUnit5() + { + + } } diff --git a/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/pom.xml b/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/pom.xml index d3ab0ab9fd..29745a98e3 100644 --- a/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/pom.xml +++ b/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/pom.xml @@ -59,6 +59,9 @@ maven-surefire-plugin + + once + diff --git a/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit4.java b/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit4.java index c0f911f2cb..b4baa8d6a6 100644 --- a/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit4.java +++ b/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit4.java @@ -8,29 +8,32 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; -@RunWith(Parameterized.class) -public class ExampleTestJUnit4 { - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { 0 }, { 1 } - }); - } - - int value; - - public ExampleTestJUnit4(int value) { - this.value = value; - } - - @Test - public void test() { - System.out.println(value); - } - - @Test - public void anotherTest() { - System.out.println("3 (and value ignored)"); - } +@RunWith( Parameterized.class ) +public class ExampleTestJUnit4 +{ + + @Parameters + public static Collection data() + { + return Arrays.asList( new Object[][] { { 0 }, { 1 } } ); + } + + int value; + + public ExampleTestJUnit4( int value ) + { + this.value = value; + } + + @Test + public void test() + { + System.out.println( value ); + } + + @Test + public void anotherTest() + { + System.out.println( "3 (and value ignored)" ); + } } diff --git a/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit5.java b/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit5.java index 89dbe21946..e944c6e920 100644 --- a/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit5.java +++ b/surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/src/test/java/de/dagere/peass/ExampleTestJUnit5.java @@ -4,17 +4,20 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -public class ExampleTestJUnit5 { +public class ExampleTestJUnit5 +{ - @ParameterizedTest - @ValueSource(ints = { 0, 1 }) - public void test(final int value) { - System.out.println(value); - } + @ParameterizedTest + @ValueSource( ints = { 0, 1 } ) + public void test( final int value ) + { + System.out.println( value ); + } - @Test - public void anotherTest() { - System.out.println("3"); - } + @Test + public void anotherTest() + { + System.out.println( "3" ); + } } \ No newline at end of file