I have written application in GWT using NetBeans. Now I want to test my application with JUnit. I have never used JUnit before but I have basic concept of how it works. Now the question is how do I setup basic Unit test to test some of my GWT Widgets. I found THIS simple example but don't know how it can be ran in NetBeans.
If you have the test file, right click on it and select "Test file", or press Ctrl+F6.
If you are using a Maven 2 project, you can add the Surefire plugin to run all the test automatically when packaging.
Related
I'm hitting a weird issue were my unit tests fail when running mvn install but they pass when running in IntelliJ.
I've looked at posts online about debugging maven, but I don't want to debug maven itself, or a maven plugin. I want to debug my unit tests when they have been called by maven. More specifically, I want to debug my code but using the Junit tests as an entry point for the debugging via a breakpoint.
Hope that makes sense.
My issue is relating to using introspection to look at some classes the application is importing from another project. This succeeds when the project is running or running in debug mode, but fails when maven runs the tests as a part of an install. i.e. the code doesn't find the classes in the other project when running under maven...
As this application uses multiple maven projects that all need to be installed, I've had to move my unit tests out into another project just so that the installs don't fail and I can carry on development.
However, for obvious reasons I would like to put my unit tests in each individual project, so am very keen to debug this and find out what is failing.
My project is called infinite-state-machine and can be found here - https://github.com/museadmin/infinite-state-machine
The unit tests are currently in their own project here - https://github.com/museadmin/infinite-state-machine-test
If anyone can advise me how to run maven in debug mode and attach IntelliJ to it so that I can set a breakpoint in my failing unit tests I will be forever in their debt :)
Thanks in advance for any help.
Brad
Situation is the following:
I've succesfully created tests in IntellijIDEA with JUnit.
Then when I rightclick on test folder to run tests I accidentally have chosen TestNG instead of JUnit. Now when I try to run tests by right click on tests folder and clicking Run"All tests" it tries to run them in TestNG, but tests are not configured for TestNG that's why I have
Test framework quit unexpectedly, No tests found in the package error
I searched through the internet, but didn't find anything on how to change testing framework by default.
Can anyone help?
Just delete the automatically created TestNG Run/Debug Configuration (Run | Edit Configurations... action) in Run Configurations dialog for the project. Then you will again have the option to choose test framework.
UPD: Since 2017.3 version there is suggest.all.run.configurations.from.context property which you can set (Help | Edit Custom Properties action) to true, then IDE will show you all the configurations that are available for current context.
TFS and TestNG - Possible to Execute TestNG test(s) within TFS2015?
I have uploaded a Java Maven project to a Repo in my instance of TFS.
My java Maven project comprises of TestNG Test / classes
I can see that there is a Maven plugin within the TFS which also has a JUnit link.
4. I cant see any option to enable me to execute TestNG tests within the TFS, is it even possible?
It's able to use Maven task to build a Java application or test the application including TestNG test. Detail steps please refer this tutorial: Get started testing Java applications with Visual Studio Team Services
For test result report just follow juherr's reply in this question.
Yes you should be able to run your TestNG tests.
I think its eventually going to be Maven that is going to be executing your tests.
Maven makes use of surefire-plugin to basically execute your tests. For TestNG here's two of executing tests via surefire-plugin
If your test matches the default pattern "/Test*.java", "/*Test.java", "**/*TestCase.java" (See here)
Create a suite xml file for TestNG (See here) and have surefire plugin refer to it (see here).
I'm using eclipse for my IDE. I'm using Maven to build / release my code. Ideally I'd like to only have 1 build engine. To that end I want to make sure that I build/test the code the same way everytime.
However, the Junit View in Eclipse is nice an easy to use. I'd like to keep using it while debugging my tests.
A couple years ago I managed to do this with Intellij IDEA, so I figure something similar should be possible in Eclipse.
How can I build (and hopefully test) with Maven and then view the results of testing in Eclipse?
The maven-surefire-plugin generates reports after executing the tests, that are located by default in target/surefire-reports:
The Surefire Plugin is used during the test phase of the build lifecycle to execute the unit tests of an application. It generates reports in two different file formats:
Plain text files (*.txt)
XML files (*.xml)
By default, these files are generated at ${basedir}/target/surefire-reports.
As such, after the tests are executed, you just need to open those reports in Eclipse by double-clicking them.
If you open the XML reports, Eclipse will, by default, open the JUnit view and you will have the same presentation as you're used to when running the test directly in Eclipse.
We have a bunch junit tests in our current project. Essentially we are looking for a way to run all the test in a given package. Currently in Netbeans I see you can run all the tests or a single test, but no way to run a a sub-set of tests.
Is this built into Netbeans? Or is there another way we can do this?
In JUnit this is achieved through TestSuite. You can check for more information here (look at the code, not at the pictures).
At least in the Eclipse IDE there is a functionality that lets you add a new TestSuite, select which tests it is to include and then have the IDE generate it for you.
I haven't seen such thing in Netbeans, but you should check for any additional JUnit plugins.
Just set up junit test groups like documented e.g. on this question and then run the test group via your ant or maven build.