NetBeans + TestNG -> "Go to source" is not possible - java

I have an huge maven project with TestNG tests. I create an new test file and add tests to it to clean my code out of bugs. I use NetBeans to run TestNG tests.
These are my issues:
The output of the tests is in text form. When I have got an stack trace, its elements are not hyperlinks (so they are not clickable). Rightclick + "Go to source" is also not possible. So I have to manually search for the class and the line with the error.
The output of the test is in text form, not like in this example: http://wiki.netbeans.org/TestNG
How could I get the stacktraces clickable?
P.P I use Netbeans 8.1.
Today I installed all pending plugin updates but the described behavior has not changed.
P.P.2 I start tests via Run -> Test File [Ctrl+F6]

This is related to two reported bugs in Netbeans.
#257563 - surefire 2.19.1 show no test results windows
solution: downgrade to surefire plugin version 2.18.1
#255883 - test results windows isn't displayed
solution: untick in the options Java -> Maven -> print maven output loggin level

Related

"No tests found in the class" is thrown when running tests in IntelliJ IDEA using TestNG framework

I have a maven project, with testng framework.
I agree I might have played around with different JAVA versions, changing project level SDK's and stuff.
So after a while when I tried to run a test using testng annotation, it would give me "no tests found in the class "
After a while I got an error which had this text->"...-Didea.test.cyclic.buffer.size=...."
So I performed below steps in IntelliJ and it was back to normal
File -> Invalidate Caches -> Clear file system cache and local history -> invalidate and restart.

How to limit BuildShip (gradle eclipse) integrated functionality?

Now that I am using gradle for all of my new development, I'm running into issues with BuildShip features I really don't want.
For instance, when I hit the Run hotkey when I have a unit test open in Eclipse, I only want it to run as a JUnit test, alone. But Gradle has inserted its own hooks and option, which means extra clicking or keypresses beyond the one-stroke hotkey I have assigned to Run that I can tell it I want JUnit. (The gradle test option actually runs all tests, which takes minutes.).
Question: Is there a way to remove this hook in gradle without diving into the source code and ripping out functionality myself?
This isn't the only interference (interfering with run last is another), but it's my #1 annoyance about BuildShip.
Essentially, I want this popup to stop happening.
Indeed you cannot change the available launchers prompt but you can change the default hotkeys related to each launcher and directly use the one you prefer.
From Windows > Preferences > General > Editor > Keys you can get the list of available hot-key mappings. Filter the (long) list by typing test as show below:
As you can see you have several mappings for running JUnit tests: Gradle, JUnit runner, Maven.
The default configuration for JUnit runner is Alt+Shift+X,T, not really user friendly I would say.
I changed it to a more concise Alt+U down in the Binding option and applied the changes. Now you can run any JUnit test on its open editor windows without any prompt, simply type Alt+U and the JUnit runner will be triggered automatically for that single unit test.
This is a major usability annoyance in Eclipse+Buildship. I perform the following steps every time Buildship upgrades to get rid of that annoying popup, and also avoid the (for me, useless) Gradle test process when what I really want is for the last test to run while I am not in that particular class. Admittedly, this is invasive, but it works while keeping the "good" parts of Buildship.
Open up the plugins folder and look for the org.eclipse.buildship.ui_*.jar. (I do this on a Mac, which requires showing the contents of the Eclipse.app first.) Open the .jar file in some zip file editor which can modify files within the zip file (I use BetterZip on Mac, I think Winzip and 7Zip probably work too.) Edit the plugin.xml file.
This is for the new Photon 4.8 release of Eclipse. Remove (or comment out) the following two sections:
The <command> element with id="org.eclipse.buildship.ui.shortcut.test.run"
The <extension> element with the comment <!-- "Gradle Test" entry in the "Run as... " context menu --> above it (about 30 lines)
Save the file, which should be noticed by BetterZip/Winzip and let it update the .jar file with the changed content. Finally, eclipse needs to be restarted with the -clean switch so that it does not use a cached copy of the jar file. For example, on Mac:
cd /Applications/eclipse-jee-photon-R-macosx-cocoa-x86_64/Eclipse.app/Contents/MacOS
/.eclipse -clean
Buildship will now no longer bother you with that popup or run the Gradle test within Eclipse, because the UI entry points have been removed. Unfortunately, on the next update of Buildship you need to repeat the process again on the new jar.

IDEA Play 2.4 junit test without full sbt build

I want to run JUnit tests for my Play 2.4 application within Intellij IDEA 14.1.4 to leverage full JUnit integration.
The tests are executed fine when I create a new JUnit run configuration. However on every test run a full SBT build is executed delaying the tests for around 30 seconds.
If I remove Make form the pre-launch steps in the JUnit run configuration the tests are executed directly without a full sbt build but then any code changes in test and application code are not picked up by IDEA. Even when the play is running with auto-compile on file changes IDEA doesn't pick them up for the tests.
Edit 07/09/2015
I've also exchanged Make with an SBT Action test:compile which only opens up a SBT console loading the project and stops with a prompt. It's not executing the action test:compile and therefore not starting the test at all.
What do I have to change in run configuration and/or project settings to get a fast and seamless JUnit integration for Play projects in IDEA?
Finally found the answer myself when digging through issue tickets of idea-sbt-plugin.
Exchanging Pre launch Step Make with SBT Action test:compile was the right way to go. However the SBT Plugin expects the default sbt shellPromt >. Play projects however define their own custom promt as [projectname] $.
I had to add the following line to build.sbt to get the SBT action to work.
shellPrompt := (_ => "> ")

Reports missing on SonarQube dashboard after upgrade

Recently I've upgraded SonarQube from 3.5 to 4.5.4 (LTS) and now there are a few users complaining that there are some reports missing on their project dashboards. The reports/numbers missing widgets are: lines of code and complexity. Unit tests coverage displays nothing. Other widgets (like technical debt, issues, directory tangle index) display 0 which also is suspicious. The project is in Java using the Sonar way profile.
The user does:
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install
mvn sonar:sonar -Dsonar.login=login -Dsonar.password=***** -Dcom.sun.jndi.ldap.connect.pool.prefsize=0 -Dcom.sun.jndi.ldap.connect.pool.timeout=3600000
The sonar:sonar step shows "0 files indexed".
The log is huge so I don't want to paste it here. I could not find anything helpful in it. What do I need to do to have all reports I used to have?
I have a test project where most of the missing data is displayed "out of the box".
Starting with version 4.3, SonarQube no longer runs automated tests. It expects Jenkins/CI system to run the tests, create the JUnit/PMD/Jacoco/Clover etc. reports, and then tell SonarQube where to find them. (In older versions of SonarQube, this behavior could be achieved by setting the "reuseReports" flag to true.)
If the build is not configured to generate the reports, it will need to be adjusted to do so.

Eclipse Kepler (4.3) JUnit (3.81) view not showing test results, using code created by maven-archetype-quickstart

Getting back into Java coding after being away for a while, downloaded the latest Maven (3.1.1), the latest Eclipse (Kepler), the latest JDK (1.7.0_45), created a new Maven project in Eclipse (using the quickstart archetype, which looks like it defaulted to JUnit 3.8.1), opened AppTest.java, selected "Run As JUnit Test" (not JUnit Plug-in Test), and nothing shows up in the JUnit view.
Shouldn't it at least say something like "Runs: 1/1"? If I change the code in testApp() to "assertTrue( false)", then I don't see a failure (although if I debug, sure enough, an exception gets thrown). If I put a println() in the test, I see its output in the console view. If I run mvn test from the command line, I get a lovely stacktrace and the word "FAILURE!" (and my println() output).
So. Something basic is wrong somewhere, but what?
Maybe you checked the "Show Failures Only" option? (on the same bar as "Rerun Test"). It happened to me :)
I think I repeat your problem. It happens when the JUnit window is opened initially in eclipse (for example I detached the view as separate window and it shows when eclipse starts).
With fresh start (window/view shown) I run tests and don't see anything in it, when I close it and run unit tests (via 'run as') window reopens but now results are shown.

Categories