New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NETBEANS-6] Adding Support for JUnit 5 #892
Conversation
Nice to see JUnit 5 support in NB, soon! ;-) Using Just scrolled through the PR and didn't find a single "junit-platform-launcher" snippet. How does NetBeans execute tests? Via the command line? Or Maven/Surefire? |
Hi @sormuras, So I toy-ed around for a while looking to see if I could implement an EngineDiscoveryRequest but couldn't get it to work, and then went back to the @testable check based on its JavaDocs and left it at that for now. When using Maven based projects, Netbeans uses Maven/Surefire - I added a quick check for Surefire >2.22.0 for supporting individual test methods. |
I see. So, at the moment, users see something like "Run test..." in the IDE/editor and when click, a Maven run tailored to the action is executed. Correct? If yes, it's good starting point. You could use the Regarding Ant and its configuration in NB ... methinks, it would need to include Or... You use the Launcher API like described here: https://junit.org/junit5/docs/current/user-guide/#launcher-api How can I test-drive this PR? Checkout your "apache/incubator-netbeans" clone, switch to branch |
Answering my last question on my own: http://netbeans.apache.org/download/index.html#source |
Thanks for the comments. NetBeans is closely tied to maven, and for JUnit surefire - I tried to keep as close to the existing solution that exists for JUnit 4 as I could to keep the changes as simple as possible. I think the biggest issue with this is the fact that surefire doesn't support the @DisplayName annotation, since the reporting in NetBeans also uses the output from Surefire from what I have seen. - So that's a gap we have with the maven support for JUnit 5 in NetBeans Yes, |
@@ -0,0 +1,24 @@ | |||
<#-- FreeMarker template (see http://freemarker.org/) --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the template file to the licenseinfo.xml if don't add the license header to template files. e.g. see https://github.com/apache/incubator-netbeans/blob/7b3b31b62e5fa95f7fbf6a60cbcc5b0838f42740/ide/xml/licenseinfo.xml#L23-L31
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @junichi11 Thanks for spotting this.
Just a note on this point though, the other licenses aren't covered in a licenseinfo.xml file, they are infact covered via the rat exclusions file: https://github.com/apache/incubator-netbeans/blob/7b3b31b62e5fa95f7fbf6a60cbcc5b0838f42740/nbbuild/rat-exclusions.txt#L188. So my new template file should be covered by this, as opposed to a licenseinfo.xml entry.
I added a new logo to differentiate JUnit 5 and the old JUnit version so will definitely add a reference to that as that was missed and commit that shortly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I suppose that we should move them to the licenseinfo.xml if possible because we have to verify rat-exclusions and licenseinfo.xml :)
@@ -0,0 +1,67 @@ | |||
<#-- FreeMarker template (see http://freemarker.org/) --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the template file to the licenseinfo.xml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above.
Regarding |
FYI: there is an issue with Surefire keeps using version 5.2 of JUnit (JUnit Platform 1.2.0) although you override the version in a |
Cool, When this comes in, then we may have to look at the Test Results window in NetBeans to show the names explicitly. |
If stars align, it should work out-of-the-box. Just update to the yet to be released Surefire version and the |
Great, if I can do something to try this out, would be great -- maybe you could update this page with the list of features provided for JUnit 5 here: https://cwiki.apache.org/confluence/display/NETBEANS/Miscellaneous |
Any reason not to merge this, what still needs to be done, etc? |
Hi, I don't think there is. |
Can you add screenshots to illustrate these features to that Miscellaneous page? |
Will do - should be able to get to that on Sunday... |
Hi, why JUnit BOM is not used in pom.xml for versions and dependencies? It looks better and more clear in my oppinion?
|
Because the current NetBeans implementation of adding libraries to an existing pom doesn't support that, as far as I could see. I tried to limit my changes to re-use a lot of what already worked with JUnit 4. It's also a matter of taste, and to me its not a big deal. |
Great, and thanks for the screenshots (https://cwiki.apache.org/confluence/display/NETBEANS/Miscellaneous). What is left to be done, for this release, and for subsequent releases? |
HI @geertjanw I cant think of anything else, I mostly focused on Maven support and maybe some ant stuff was handle there, but there probably some work there if someone who uses ant wants to take on. I think for this release we should be okay, and we'll need to update the Test Specs for JUnit testing for NetCat to help test this a little more. Moving forward, for subsequent releases: Apart from that I don't see anything as Surefire should be fixing their display name annotation handling issue, if that doesn't need any additional changes then great, if not we can include that in a future release. |
Great. Let's merge if no one objects 24 hours from now. |
We want to cut a new Surefire Version 2.22.1 for JUnit5 5.2.0+. |
I took a look at JUnit 5 and Ant in NetBeans, some thoughts here: https://blogs.apache.org/netbeans/entry/junit-5-apache-ant-and |
Have you tried the all-in-one-fat-jar solution with Ant? Download junit-platform-console-standalone and that's all. Copied from the User Guide
|
Ah, OK, that's great. Could we bundle that with Apache NetBeans, in the same way that we're currently bundling jupiter-api, jupiter-params, and jupiter-engine? And could we remove those three and replace it with the fat JAR? Is it licensed in the same way? |
Perhaps. It's a "all-in" solution. Could Maven projects still refer to the modules and use them while Ant projects get the
It states:
It contains the following licences:
|
@geertjanw Here is an example of a "patched" Ant installation that allows Ant projects to be configured hassle-free: https://github.com/junit-team/junit5-samples/tree/master/junit5-jupiter-starter-ant See https://github.com/junit-team/junit5-samples/blob/master/junit5-jupiter-starter-ant/build.sh#L6-L20 for how to "install" the |
Yes, I've been studying this one a lot, it's great and very useful: https://github.com/junit-team/junit5-samples/blob/master/junit5-jupiter-starter-ant/build.xml And the org.junit.platform.console.ConsoleLauncher works fine, produces results, etc. The only question is how to hook it into the Results Window in NetBeans, which is done very well for Surefire, which is why JUnit 5 with Maven in NetBeans works so smoothly in this regard. |
By a listener that Surefire calls when tests are executed? Nevertheless and as you have written in your blog, NetBeans should use the JUnit Platform Launcher API to start test runs. That's the sole purpose of it -- no need to depend on a plugin of a specific build tool that tries to "find and execute" tests in a "custom" way. Copied from the beginning of the User Guide:
https://junit.org/junit5/docs/current/user-guide/index.html#overview-what-is-junit-5 And every new TestEngine, wrapping an existing test framework (mainrunner, TestNG, Spock, JQWIK, ... https://github.com/junit-team/junit5/wiki/Third-party-Extensions#junit-platform-test-engines) or one that is invented tomorrow (JUnit 6 "aka Saturn") will be integrated in your build tool right-away. Zero effort. |
Main Features include: