matthiasblaesing commented on PR #3995:
URL: https://github.com/apache/netbeans/pull/3995#issuecomment-2941330684

   For the name problem: I read a bit and I think I would be ok with merging. 
   
   For the code updates - I don't think this works correctly yet. I created a 
maven project with our sample code (adjusted method names to better see the 
differences):
   
   ```xml
   <?xml version="1.0" encoding="UTF-8"?>
   <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>
       <groupId>test</groupId>
       <artifactId>TestNested</artifactId>
       <version>1.0-SNAPSHOT</version>
       <packaging>jar</packaging>
       <properties>
           <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
           <maven.compiler.release>17</maven.compiler.release>
           <exec.mainClass>test.testnested.TestNested</exec.mainClass>
       </properties>
       <dependencies>
           <dependency>
               <groupId>org.junit.jupiter</groupId>
               <artifactId>junit-jupiter-api</artifactId>
               <version>5.11.3</version>
               <scope>test</scope>
               <type>jar</type>
           </dependency>
           <dependency>
               <groupId>org.junit.jupiter</groupId>
               <artifactId>junit-jupiter-params</artifactId>
               <version>5.11.3</version>
               <scope>test</scope>
               <type>jar</type>
           </dependency>
       </dependencies>
   </project>
   ```
   
   ```java
   import org.junit.jupiter.api.Nested;
   import org.junit.jupiter.api.Test;
   
   public class SampleTest {
     @Test
     public void testMyMethod1() {
       System.out.println("write this");
     }
     @Nested
     class NestedClass {
       @Test
       public void testMyMethod2() {
         System.out.println("nested write 2");
       }
     }
     @Nested
     class NestedClass2 {
       @Test
       public void testMyMethod3() {
         System.out.println("nested write 1");
       }
       @Test
       public void testMyMethod4() {
         System.out.println("nested write 3");
       }
       @Nested
       class DoubleNestedClass3 {
         @Test
         public void testMyMethod5() {
           System.out.println("double nested write 4");
         }
         @Test
         public void testmyMethod6() throws Exception {
           throw new Exception();
         }
       }
     }
   }
   ```
   </detail>
   
   When I run "Test" from the projects context menu I see:
   
   
![grafik](https://github.com/user-attachments/assets/9ab3277c-6496-415d-98a4-99a7df5c9716)
   
   ```
   cd /tmp/TestNested; JAVA_HOME=/home/matthias/bin/jdk-17 
/home/matthias/src/netbeans/nbbuild/netbeans/java/maven/bin/mvn 
--no-transfer-progress test
   ```
   
   What I would have expected:
   
   - `testMyMethod1` should be shown under `SampleTest`
   - `testMyMethod2` should be shown under `SampleTest$NestedClass`
   - `testMyMethod3` should be shown under `SampleTest$NestedClass2`
   - `testMyMethod4` should be shown under `SampleTest$NestedClass2`
   
   When I choose "Test File" from the context menu in the editor window in 
`SampleTest.java` I get:
   
   
![grafik](https://github.com/user-attachments/assets/772df44d-1fd3-44de-9ddb-360a4aa7c197)
   
   ```
   cd /tmp/TestNested; JAVA_HOME=/home/matthias/bin/jdk-17 
/home/matthias/src/netbeans/nbbuild/netbeans/java/maven/bin/mvn 
-Dtest=SampleTest,SampleTest$* --no-transfer-progress process-test-classes 
surefire:test
   ```
   
   - `testMyMethod1`, `testMyMethod3` and `testMyMethod4` are not 
execute/analyzed
   
   When I try to run a single method from the test file directly:
   
   
![grafik](https://github.com/user-attachments/assets/269e4bb8-d7a3-4988-80d6-dfd172b669c9)
   
   This fails for `testMyMethod1` with an exception:
   
   ```
   SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor 
org.netbeans.modules.maven.ActionProviderImpl$$Lambda$1096/0x0000782694f2ec20
   java.lang.NullPointerException: Cannot invoke 
"org.netbeans.spi.project.NestedClass.getClassName()" because the return value 
of "org.netbeans.spi.project.SingleMethod.getNestedClass()" is null
        at 
org.netbeans.modules.maven.execute.DefaultReplaceTokenProvider.createReplacements(DefaultReplaceTokenProvider.java:250)
        at 
org.netbeans.modules.maven.ActionProviderImpl.replacements(ActionProviderImpl.java:426)
        at 
org.netbeans.modules.maven.ActionProviderImpl.invokeAction(ActionProviderImpl.java:308)
        at 
org.netbeans.modules.maven.ActionProviderImpl.lambda$invokeAction$4(ActionProviderImpl.java:281)
        at 
org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1403)
        at 
org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
        at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
        at 
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2018)
   ```
   
   For `testMyMethod2` it fails a bit different:
   
   Invocation:
   
   ```
   cd /tmp/TestNested; JAVA_HOME=/home/matthias/bin/jdk-17 
/home/matthias/src/netbeans/nbbuild/netbeans/java/maven/bin/mvn 
-Dtest=SampleTestNestedClass#testMyMethod2 --no-transfer-progress 
process-test-classes surefire:test
   ```
   
   Result:
   
   ```
   Failed to execute goal 
org.apache.maven.plugins:maven-surefire-plugin:3.2.5:test (default-cli) on 
project TestNested: No tests matching pattern 
"SampleTestNestedClass#testMyMethod2" were executed! (Set 
-Dsurefire.failIfNoSpecifiedTests=false to ignore this error.) -> [Help 1]
   ```
   
   For the change to `Classpath.java`: As indicated breaking API contract is 
not acceptable. I wanted to have a look at what breaks when I remove the 
change, but the points above invalidated that quest.
   


-- 
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: notifications-unsubscr...@netbeans.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to