Bernard created NETBEANS-3733:
---------------------------------

             Summary: Cannot test single method with Maven and Junit 5
                 Key: NETBEANS-3733
                 URL: https://issues.apache.org/jira/browse/NETBEANS-3733
             Project: NetBeans
          Issue Type: Bug
          Components: java - JUnit, projects - Maven
    Affects Versions: 11.2, 11.1
            Reporter: Bernard


All defaults, hello world application as simple as possible.

How to reproduce:

Menu|File|New Project|Java with Maven|Java Application|Finish
Projects|New|java Class|NewClass|Finish

Add two methods:

public void hello1() {
 System.out.println("Hello 1");
 }
 
 public void hello2() {
 System.out.println("Hello 2");
 }

[Ctrl+Shift+U] Create / Update Tests|JUnit|OK

generates test as expected, adds dependencies to POM as expected:

<dependencies>
 <dependency>
 <groupId>org.junit.jupiter</groupId>
 <artifactId>junit-jupiter-api</artifactId>
 <version>5.3.1</version>
 <scope>test</scope>
 </dependency>
 <dependency>
 <groupId>org.junit.jupiter</groupId>
 <artifactId>junit-jupiter-params</artifactId>
 <version>5.3.1</version>
 <scope>test</scope>
 </dependency>
 <dependency>
 <groupId>org.junit.jupiter</groupId>
 <artifactId>junit-jupiter-engine</artifactId>
 <version>5.3.1</version>
 <scope>test</scope>
 </dependency>
 </dependencies>

In generated class NewClassTest now I want to test the single method 
"testHello2()"

So I put cursor on it and right click, "Run Focused Test Method".

I get a dialog:

"Feature requires update of POM"

"Executing single test method requires Surefire 2.8+ and JUnit in version 4.8 
and bigger.
Update your pom.xml?"

I click "Yes"

In pom.xml, another dependecy is added:

<dependency>
 <artifactId>junit</artifactId>
 <groupId>junit</groupId>
 <version>4.11</version>
 </dependency>

Si I try again. Put cursor on the method and right click, "Run Focused Test 
Method".


I get a message

"No tests executed for mavenproject1"


This means that I cannot use the default way of NetBeans to quickly create a 
class and test it.

This reproduces with all only defaults selected such as Java Maven project, as 
simple as it can get. This has worked for about 10 years until it was broken 
with JUnit 5.

How can we select JUnit 4 until this is mature?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-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