You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "TheRealHaui (via GitHub)" <gi...@apache.org> on 2025/11/19 20:47:37 UTC

[PR] Add new Unit Tests [maven]

TheRealHaui opened a new pull request, #11470:
URL: https://github.com/apache/maven/pull/11470

   Add new Unit Tests to increase test coverage


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


Re: [PR] Add new Unit Tests [maven]

Posted by "TheRealHaui (via GitHub)" <gi...@apache.org>.
TheRealHaui commented on PR #11470:
URL: https://github.com/apache/maven/pull/11470#issuecomment-3580960958

   @gnodet,
   internal code comments adapted. 


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


Re: [PR] Add new Unit Tests [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet merged PR #11470:
URL: https://github.com/apache/maven/pull/11470


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


Re: [PR] Add new Unit Tests [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #11470:
URL: https://github.com/apache/maven/pull/11470#discussion_r2564031224


##########
impl/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java:
##########
@@ -212,6 +219,39 @@ void testAddDotFile() {
         assertEquals(1, project.getCompileSourceRoots().size());
     }
 
+    @Test
+    void testRemoveSourceRoot() {
+        MavenProject project = new MavenProject();
+
+        File basedir = new File(System.getProperty("java.io.tmpdir"));
+        project.setFile(new File(basedir, "file"));
+
+        assertEquals(0, project.getSourceRoots().size());
+
+        project.addSourceRoot(new DefaultSourceRoot(ProjectScope.MAIN, Language.JAVA_FAMILY, Path.of(basedir.getAbsolutePath(),"src/main/java")));
+
+        assertEquals(1, project.getSourceRoots().size());
+
+        //Try remove
+        //different directory

Review Comment:
   ```suggestion
           // Try to remove a different directory
   ```



##########
impl/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java:
##########
@@ -212,6 +219,39 @@ void testAddDotFile() {
         assertEquals(1, project.getCompileSourceRoots().size());
     }
 
+    @Test
+    void testRemoveSourceRoot() {
+        MavenProject project = new MavenProject();
+
+        File basedir = new File(System.getProperty("java.io.tmpdir"));
+        project.setFile(new File(basedir, "file"));
+
+        assertEquals(0, project.getSourceRoots().size());
+
+        project.addSourceRoot(new DefaultSourceRoot(ProjectScope.MAIN, Language.JAVA_FAMILY, Path.of(basedir.getAbsolutePath(),"src/main/java")));
+
+        assertEquals(1, project.getSourceRoots().size());
+
+        //Try remove
+        //different directory
+        project.removeSourceRoot(ProjectScope.MAIN, Language.JAVA_FAMILY, "src/test/java");
+
+        assertEquals(1, project.getSourceRoots().size());
+
+        //Try remove
+        //different scope

Review Comment:
   ```suggestion
           // Try to remove a different scope
   ```



##########
impl/maven-core/src/test/java/org/apache/maven/project/MavenProjectTest.java:
##########
@@ -212,6 +219,39 @@ void testAddDotFile() {
         assertEquals(1, project.getCompileSourceRoots().size());
     }
 
+    @Test
+    void testRemoveSourceRoot() {
+        MavenProject project = new MavenProject();
+
+        File basedir = new File(System.getProperty("java.io.tmpdir"));
+        project.setFile(new File(basedir, "file"));
+
+        assertEquals(0, project.getSourceRoots().size());
+
+        project.addSourceRoot(new DefaultSourceRoot(ProjectScope.MAIN, Language.JAVA_FAMILY, Path.of(basedir.getAbsolutePath(),"src/main/java")));
+
+        assertEquals(1, project.getSourceRoots().size());
+
+        //Try remove
+        //different directory
+        project.removeSourceRoot(ProjectScope.MAIN, Language.JAVA_FAMILY, "src/test/java");
+
+        assertEquals(1, project.getSourceRoots().size());
+
+        //Try remove
+        //different scope
+        project.removeSourceRoot(ProjectScope.TEST, Language.JAVA_FAMILY, "src/main/java");
+
+        assertEquals(1, project.getSourceRoots().size());
+
+        //Remove previously
+        //added root

Review Comment:
   ```suggestion
           // Remove previously added root
   ```



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