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/10/18 00:41:22 UTC

[GitHub] [maven-invoker] iofit opened a new pull request, #56: [MSHARED-1152] - Migrate tests to JUnit5

iofit opened a new pull request, #56:
URL: https://github.com/apache/maven-invoker/pull/56

   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/projects/MSHARED) 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 `[MSHARED-XXX] - Fixes bug in ApproximateQuantiles`,
          where you replace `MSHARED-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 verify` to make sure basic checks pass. A more thorough check will 
          be performed on your pull request automatically.
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
   please ask on the developers list.
   
   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)
   
    - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   


-- 
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-invoker] iofit commented on a diff in pull request #56: [MSHARED-1152] - Migrate tests to JUnit5

Posted by GitBox <gi...@apache.org>.
iofit commented on code in PR #56:
URL: https://github.com/apache/maven-invoker/pull/56#discussion_r998744020


##########
src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java:
##########
@@ -857,46 +846,46 @@ public void testShouldInsertActivatedProfiles()
     public void testMvnExecutableFromInvoker()
         throws Exception
     {
-        assumeThat( "Test only works when maven.home is set",
-            System.getProperty( "maven.home" ), is(notNullValue()));
+        assumingThat( Objects.nonNull(System.getProperty( "maven.home" )),
+                () -> System.out.println("Test only works when maven.home is set"));

Review Comment:
   Hi, `assumeThat` doesn't either, it ignores the test, and `assumingThat` does the same, do we want the test to fail if the assumption is not met? If so, that would be an assertion instead and we would have to rewrite expectations. 
   [https://junit.org/junit4/javadoc/4.12/org/junit/Assume.html#assumeThat(java.lang.String,%20T,%20org.hamcrest.Matcher)](https://junit.org/junit4/javadoc/4.12/org/junit/Assume.html#assumeThat(java.lang.String,%20T,%20org.hamcrest.Matcher))



-- 
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-invoker] slawekjaranowski commented on a diff in pull request #56: [MSHARED-1152] - Migrate tests to JUnit5

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on code in PR #56:
URL: https://github.com/apache/maven-invoker/pull/56#discussion_r1000439724


##########
src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java:
##########
@@ -857,46 +846,46 @@ public void testShouldInsertActivatedProfiles()
     public void testMvnExecutableFromInvoker()
         throws Exception
     {
-        assumeThat( "Test only works when maven.home is set",
-            System.getProperty( "maven.home" ), is(notNullValue()));
+        assumingThat( Objects.nonNull(System.getProperty( "maven.home" )),
+                () -> System.out.println("Test only works when maven.home is set"));

Review Comment:
   Ok, I think that whole test should be ignored.
   - old `assumeThat` skip test if condition is not meet
   - but `assumingThat` only skips execution of provided lambda not whole test



-- 
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-invoker] iofit commented on a diff in pull request #56: [MSHARED-1152] - Migrate tests to JUnit5

Posted by GitBox <gi...@apache.org>.
iofit commented on code in PR #56:
URL: https://github.com/apache/maven-invoker/pull/56#discussion_r1001364433


##########
src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java:
##########
@@ -857,46 +846,46 @@ public void testShouldInsertActivatedProfiles()
     public void testMvnExecutableFromInvoker()
         throws Exception
     {
-        assumeThat( "Test only works when maven.home is set",
-            System.getProperty( "maven.home" ), is(notNullValue()));
+        assumingThat( Objects.nonNull(System.getProperty( "maven.home" )),
+                () -> System.out.println("Test only works when maven.home is set"));

Review Comment:
   I think you're right, I missed that specific part, thank you for catching it, I've replaced assumingThat with assumeTrue which should abort/skip the test if the condition is not met.



-- 
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-invoker] slawekjaranowski merged pull request #56: [MSHARED-1152] - Migrate tests to JUnit5

Posted by GitBox <gi...@apache.org>.
slawekjaranowski merged PR #56:
URL: https://github.com/apache/maven-invoker/pull/56


-- 
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-invoker] slawekjaranowski commented on a diff in pull request #56: [MSHARED-1152] - Migrate tests to JUnit5

Posted by GitBox <gi...@apache.org>.
slawekjaranowski commented on code in PR #56:
URL: https://github.com/apache/maven-invoker/pull/56#discussion_r997721215


##########
src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java:
##########
@@ -19,57 +19,46 @@
  * under the License.
  */
 
+import org.apache.maven.shared.utils.Os;
+import org.apache.maven.shared.utils.cli.Commandline;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.*;

Review Comment:
   Incorrect order.



##########
src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java:
##########
@@ -19,57 +19,46 @@
  * under the License.
  */
 
+import org.apache.maven.shared.utils.Os;
+import org.apache.maven.shared.utils.cli.Commandline;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.*;
 
-import org.apache.maven.shared.utils.Os;
-import org.apache.maven.shared.utils.cli.Commandline;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeThat;
+import static org.junit.jupiter.api.Assertions.*;

Review Comment:
   Don't use wildcard imports.



##########
src/test/java/org/apache/maven/shared/invoker/DefaultInvokerTest.java:
##########
@@ -19,20 +19,19 @@
  * under the License.
  */
 
+import org.apache.maven.shared.utils.Os;
+import org.apache.maven.shared.utils.StringUtils;
+import org.junit.jupiter.api.Test;
+
 import java.io.File;
-import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Properties;
 
-import org.apache.maven.shared.utils.Os;
-import org.apache.maven.shared.utils.StringUtils;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;

Review Comment:
   Please follow: https://maven.apache.org/developers/conventions/code.html#java-code-convention-import-layouts



##########
src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java:
##########
@@ -109,7 +98,7 @@ public void testShouldFailToSetLocalRepoLocationFromRequestWhenItIsAFile()
     @Test
     public void testShouldSetLocalRepoLocationGlobally() throws IOException
     {
-        File lrd = temporaryFolder.newFolder( "workdir" ).getCanonicalFile();
+        File lrd = Files.createDirectory(temporaryFolder.resolve("workdir")).toFile().getCanonicalFile();

Review Comment:
   Please follow: https://maven.apache.org/developers/conventions/code.html in whole file.
   
   Should be:
   ```suggestion
           File lrd = Files.createDirectory( temporaryFolder.resolve( "workdir" ) ).toFile().getCanonicalFile();
   ```
   
   missing spaces



##########
src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java:
##########
@@ -857,46 +846,46 @@ public void testShouldInsertActivatedProfiles()
     public void testMvnExecutableFromInvoker()
         throws Exception
     {
-        assumeThat( "Test only works when maven.home is set",
-            System.getProperty( "maven.home" ), is(notNullValue()));
+        assumingThat( Objects.nonNull(System.getProperty( "maven.home" )),
+                () -> System.out.println("Test only works when maven.home is set"));

Review Comment:
   `assumingThat` doesn't break a test ...
   
   https://junit.org/junit5/docs/current/api/org.junit.jupiter.api/org/junit/jupiter/api/Assumptions.html#assumingThat(boolean,org.junit.jupiter.api.function.Executable)



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