[jira] [Comment Edited] (NETBEANS-3733) Cannot test single method with Maven and Junit 5

2020-05-17 Thread Svatopluk Dedic (Jira)


[ 
https://issues.apache.org/jira/browse/NETBEANS-3733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17109375#comment-17109375
 ] 

Svatopluk Dedic edited comment on NETBEANS-3733 at 5/17/20, 7:39 AM:
-

I did reproduce using the steps in the initial comment. I'm not sure if it 
qualifies to {{Critical}} as a workaround exists:
 * you seem to use *JUnit 5*, the added dependency is *JUnit 4*, which is 
probably NOT what you'd want. Remove the added dependency and add Junit's 5 
package to shut NetBeans up:

{code:java}

org.junit.vintage
junit-vintage-engine
5.6.0
test
{code}
 * Despite [Maven 
Documentation|https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html]
 says that the syntax {{ClassName#method}} works from *surefire 2.7.3*, I was 
able to get it work only for *surefire 2.22.0* and above. I have Maven *3.6.0* 
installed separately and on my installation, *surefire 2.12.4* is used by 
default. Check (run with -X, show debug output) if it is your case. Update your 
{{pom.xml}} with

{code:java}




org.apache.maven.plugins
maven-surefire-plugin
2.22.0





{code}
to force *2.22.0* version

Of course NB JUnit support *should* recognize JUnit Jupiter artifacts and "do 
the right thing". 


was (Author: sdedic):
I did reproduce using the steps in the initial comment. I'm not sure if it 
qualifies to {{Critical}} as a workaround exists:
 * you seem to use *JUnit 5*, the added dependency is *JUnit 4*, which is 
probably NOT what you'd want. Remove the added dependency and add Junit's 5 
package to shut NetBeans up:

{code:java}

org.junit.vintage
junit-vintage-engine
5.6.0
test
{code}

 * Despite [Maven 
Documentation|[https://maven.apache.org/surefire/maven-surefire-plugin/examples/single-test.html]]
 says that the syntax {{ClassName#method}} works from *surefire 2.7.3*, I was 
able to get it work only for *surefire 2.22.0* and above. I have Maven *3.6.0* 
installed separately and on my installation, *surefire 2.12.4* is used by 
default. Check (run with -X, show debug output) if it is your case. Update your 
{{pom.xml}} with

{code:java}




org.apache.maven.plugins
maven-surefire-plugin
2.22.0





{code}
to force *2.22.0* version

Of course NB JUnit support *should* recognize JUnit Jupiter artifacts and "do 
the right thing". 

> 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.1, 11.2, 11.3
>Reporter: Bernard
>Priority: Critical
>
> 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:
> 
>  
>  org.junit.jupiter
>  junit-jupiter-api
>  5.3.1
>  test
>  
>  
>  org.junit.jupiter
>  junit-jupiter-params
>  5.3.1
>  test
>  
>  
>  org.junit.jupiter
>  junit-jupiter-engine
>  5.3.1
>  test
>  
>  
> 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:
> 
>  junit
>  junit
>  4.11
>  
> 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.

[jira] [Comment Edited] (NETBEANS-3733) Cannot test single method with Maven and Junit 5

2020-04-28 Thread Jira


[ 
https://issues.apache.org/jira/browse/NETBEANS-3733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17094771#comment-17094771
 ] 

Paulo Tibério Bulhões edited comment on NETBEANS-3733 at 4/28/20, 6:47 PM:
---

I ran into the same problem and I used to solution at 
[https://springframework.guru/why-your-junit-5-tests-are-not-running-under-maven/.|https://springframework.guru/why-your-junit-5-tests-are-not-running-under-maven/]
  I.e., edit the pom file and add dependencies for maven-surefire-plugin 
version 2.22.0.  It worked fine for me but I am new to netbeans and there might 
be better solutions. I am using netbeans 11.3


was (Author: cmpyl0):
I ran into the same problem and I used to solution at 
[https://springframework.guru/why-your-junit-5-tests-are-not-running-under-maven/.|https://springframework.guru/why-your-junit-5-tests-are-not-running-under-maven/]
  I.e., edit the pom file and add dependencies for maven-surefire-plugin 
version 2.22.0.  It worked fine for me but I am new to netbeans and there might 
be better solutions.

> 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.1, 11.2, 11.3
>Reporter: Bernard
>Priority: Major
>
> 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:
> 
>  
>  org.junit.jupiter
>  junit-jupiter-api
>  5.3.1
>  test
>  
>  
>  org.junit.jupiter
>  junit-jupiter-params
>  5.3.1
>  test
>  
>  
>  org.junit.jupiter
>  junit-jupiter-engine
>  5.3.1
>  test
>  
>  
> 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:
> 
>  junit
>  junit
>  4.11
>  
> 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



[jira] [Comment Edited] (NETBEANS-3733) Cannot test single method with Maven and Junit 5

2020-01-23 Thread Bernard (Jira)


[ 
https://issues.apache.org/jira/browse/NETBEANS-3733?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17022571#comment-17022571
 ] 

Bernard edited comment on NETBEANS-3733 at 1/23/20 10:46 PM:
-

This might be helpful:

https://stackoverflow.com/questions/45919894/maven-and-junit-5-run-a-single-test-in-a-class


was (Author: bht):
This might be helpful:

[Maven and JUnit 5: run a single test in a 
class|[http://example.com|https://stackoverflow.com/questions/45919894/maven-and-junit-5-run-a-single-test-in-a-class]]

> 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.1, 11.2
>Reporter: Bernard
>Priority: Major
>
> 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:
> 
>  
>  org.junit.jupiter
>  junit-jupiter-api
>  5.3.1
>  test
>  
>  
>  org.junit.jupiter
>  junit-jupiter-params
>  5.3.1
>  test
>  
>  
>  org.junit.jupiter
>  junit-jupiter-engine
>  5.3.1
>  test
>  
>  
> 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:
> 
>  junit
>  junit
>  4.11
>  
> 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