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 2022/02/24 14:28:53 UTC

[GitHub] [maven-surefire] DaGeRe opened a new pull request #476: [SUREFIRE-2010] Parameterized Selection Does not Work

DaGeRe opened a new pull request #476:
URL: https://github.com/apache/maven-surefire/pull/476


   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](https://issues.apache.org/jira/browse/SUREFIRE) 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](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
    - [x] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
   


-- 
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



[GitHub] [maven-surefire] DaGeRe commented on a change in pull request #476: [SUREFIRE-2010] Parameterized Selection Does not Work

Posted by GitBox <gi...@apache.org>.
DaGeRe commented on a change in pull request #476:
URL: https://github.com/apache/maven-surefire/pull/476#discussion_r821839957



##########
File path: 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();

Review comment:
       Yes, this was only for starting. The plan is to run it once with all tests and than with a selector.
   
   Now, I've added
   ```
   TestFile surefireReportsFile = validator.getSurefireReportsFile( "de.dagere.peass.ExampleTestJUnit4.txt" );
   surefireReportsFile.assertContainsText( "Tests run: 2" );
   ```
   which unfortunately fails.

##########
File path: surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/pom.xml
##########
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>

Review comment:
       Thanks, I've added the `forkMode`.




-- 
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



[GitHub] [maven-surefire] Tibor17 commented on pull request #476: [SUREFIRE-2010] Parameterized Selection Does not Work

Posted by GitBox <gi...@apache.org>.
Tibor17 commented on pull request #476:
URL: https://github.com/apache/maven-surefire/pull/476#issuecomment-1050764482


   @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#test[1]` and the IT allows you to assert lines in the logs and XML reports too.


-- 
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



[GitHub] [maven-surefire] Tibor17 commented on pull request #476: [SUREFIRE-2010] Parameterized Selection Does not Work

Posted by GitBox <gi...@apache.org>.
Tibor17 commented on pull request #476:
URL: https://github.com/apache/maven-surefire/pull/476#issuecomment-1050062272


   Hi @DaGeRe ,
   
   The JIRA is not well suite to read code patches. So even if the test fails, we can discuss the code even if the CI would fail.


-- 
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



[GitHub] [maven-surefire] DaGeRe commented on pull request #476: [SUREFIRE-2010] Parameterized Selection Does not Work

Posted by GitBox <gi...@apache.org>.
DaGeRe commented on pull request #476:
URL: https://github.com/apache/maven-surefire/pull/476#issuecomment-1061966185


   Thanks for the hints. I adapted the code, but have two questions:
   - Is there a guide how to debug this? I can start the test on command line and see it failing, but not in eclipse. This makes debugging much harder.
   - 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]
   ```


-- 
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



[GitHub] [maven-surefire] Tibor17 edited a comment on pull request #476: [SUREFIRE-2010] Parameterized Selection Does not Work

Posted by GitBox <gi...@apache.org>.
Tibor17 edited a comment on pull request #476:
URL: https://github.com/apache/maven-surefire/pull/476#issuecomment-1050062272


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


-- 
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



[GitHub] [maven-surefire] Tibor17 commented on a change in pull request #476: [SUREFIRE-2010] Parameterized Selection Does not Work

Posted by GitBox <gi...@apache.org>.
Tibor17 commented on a change in pull request #476:
URL: https://github.com/apache/maven-surefire/pull/476#discussion_r814680211



##########
File path: surefire-its/src/test/resources/surefire-2010-parameterized-selection-does-not-work/pom.xml
##########
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>

Review comment:
       Due to this parent POM specifies `<forkMode>never</forkMode>` it is a problem for all ITs and the tests won't run in a fork mode. There are two alternatives how to solve this. Override the parameter to the default value `<forkMode>once</forkMode>` or use `<version>${surefire.version}</version>`.




-- 
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



[GitHub] [maven-surefire] Tibor17 commented on a change in pull request #476: [SUREFIRE-2010] Parameterized Selection Does not Work

Posted by GitBox <gi...@apache.org>.
Tibor17 commented on a change in pull request #476:
URL: https://github.com/apache/maven-surefire/pull/476#discussion_r814676994



##########
File path: 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();

Review comment:
       `OutputValidator validator =` is useless.




-- 
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



[GitHub] [maven-surefire] DaGeRe commented on a change in pull request #476: [SUREFIRE-2010] Parameterized Selection Does not Work

Posted by GitBox <gi...@apache.org>.
DaGeRe commented on a change in pull request #476:
URL: https://github.com/apache/maven-surefire/pull/476#discussion_r821840505



##########
File path: 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)

Review comment:
       Thank, I've imported the style and hopefully reformatted it correctly.




-- 
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



[GitHub] [maven-surefire] DaGeRe edited a comment on pull request #476: [SUREFIRE-2010] Parameterized Selection Does not Work

Posted by GitBox <gi...@apache.org>.
DaGeRe edited a comment on pull request #476:
URL: https://github.com/apache/maven-surefire/pull/476#issuecomment-1061966185


   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.
   


-- 
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



[GitHub] [maven-surefire] Tibor17 edited a comment on pull request #476: [SUREFIRE-2010] Parameterized Selection Does not Work

Posted by GitBox <gi...@apache.org>.
Tibor17 edited a comment on pull request #476:
URL: https://github.com/apache/maven-surefire/pull/476#issuecomment-1050062272


   Hi @DaGeRe ,
   
   The JIRA is not well suited to read code patches. So even if the test fails, we can discuss the code even if the CI would fail.


-- 
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



[GitHub] [maven-surefire] Tibor17 commented on a change in pull request #476: [SUREFIRE-2010] Parameterized Selection Does not Work

Posted by GitBox <gi...@apache.org>.
Tibor17 commented on a change in pull request #476:
URL: https://github.com/apache/maven-surefire/pull/476#discussion_r814682655



##########
File path: 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)

Review comment:
       It would be nice to adjust the code style in these files well.
   Pls configure your IDE, here is instructions and code style XML for your IDEs:
   https://maven.apache.org/developers/conventions/code.html#intellij-idea




-- 
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



[GitHub] [maven-surefire] Tibor17 edited a comment on pull request #476: [SUREFIRE-2010] Parameterized Selection Does not Work

Posted by GitBox <gi...@apache.org>.
Tibor17 edited a comment on pull request #476:
URL: https://github.com/apache/maven-surefire/pull/476#issuecomment-1050764482


   @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


-- 
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