JUnit Eclipse Oxygen - Display stack trace on test failure? - java

Is there a way to have eclipse show junit assertion errors (or more generally unhandled exceptions during testing for that matter) automatically without me going to the junit window, selecting the failed test, clicking the corresponding line on the right side, and then clicking the corresponding button each single time? This is ludicrous. There surely must be a better way I have not found yet!

Related

JUnit Stopping at Breakpoints in Files I Didn't Write and Don't Have Permission to

I am running unit tests on java code using intelliJ and junit. The unit tests were working fine, and they still are . . . until I run in debug mode. Today, when I run in debug mode, all of a sudden, they start iterating through java files that are installed with java, I didn't write, and that I don't have permission for like the following:
This is part of the java code base that I don't have any control over and I didn't set any breakpoint here. Yet it pauses here and makes me click through it to get past it. I wouldn't care if this was only a couple of additional clicks to click through, but I have clicked like 50 times and it still keeps going through base java code that I have no control over and is not what is throwing any problem or issue.
I tried changing the settings for code coverage but that didn't seem to do anything. Is there any way to get junit to only stop at breakpoints that I, myself, specified? Any help here would be appreciated. I didn't see a similar question on Stack Overflow and the stuff on other sites is all about crafting the unit test itself.
So crazy coder (see above) was correct, but I thought I would add (after painfully trying every other alternative) that you have to go to: Run | View Breakpoints and then scroll all the way down on the left side panel (which you may not notice if you have tons of breakpoints like I did) and at the bottom there are breakpoints for Java exceptions. You need to click those OFF see below:

clear test history intellij?

Intellij keeps track of test (JUnit) history, which is very nice...
But it registers failing tests as 'problem', which get triggered by commit-checks. I want to commit non-working tests at the end of the day, so I want to be able to clear the test-history.
However, I can't find that option anywhere, nor does 'delete' work on the selected test-run.
How to clear all of the test history?
In Settings, Editor, Inspections, select "Failed line in test" and turn the severity down to "Weak Warning"
A workaround would be to comment the non working tests, then run it again and commit it with only working tests.
Also the put TODO in the comments of the non working tests, so that you know that you have to check them later on.

JUNIT 5 report collapsing automatically

When I'm running my tests on JUNIT 5, its report automatically collapses between one parameterized test and another during execution:
For example, when the 1st Device is running, the run report is opened like that. When the first test finishes and goes to the second run, all these lines collapses and I need to right-click the "TestCases" at the top and click on "Expand All" option.
Not sure if this is clear, I wish I could record a gif, but I'd like to know if there is an option to JUNIT do not collapse the executions automatically, because sometimes I want to follow the execution in real-time and see if any of the tests got an error, and not just at the end of the execution.
JUnit is just sending out „events“ to your IDE about tests being started and finished. JUnit has no control over how the IDE will animate this stream of events.
So I recommend that you open a feature request for your IDE vendor.

How to skip a failed STEP on a TEST with Serenity-Cucumber

I use a Maven project with Java, Selenium WebDriver, JUnit, and Serenity with Screenplay.
I have a login with a pop-up that only appears sometimes, how can I add a validation STEP for the pop-up without failing the whole TEST if the pop-up doesn't appear?
Put in the test, in try-catch waiting for the popup. If it will appear - make needed actions, then go to next step, if don't appear - then just go to the next steps.
Here is almost same question with good answer: Executing scenario even if one of the step is failed

Netbeans with Java how to find the source of an error?

I use Netbeans for my Java IDE. I am building off a 3rd party API. I have built quite a bit on top of it. I try to leave good debugging messages around my code, but I am getting a very basic error message, then my program is closing. I get this Error - java.io.EOFException and then shortly after the program closes. I think it is just a system output printed line showing the error coming from the API.
Does anyone know of a technique in Netbeans of Java in general where I could identify where the error is coming from?
One can put a break point on the constructor for EOFException().
To do so:
From the menu select Window -> Debugging -> Breakpoints or (Alt+Shift+5)
In the Breakpoints window, right click for pop-up and choose New Breakpoint ...
Set Breakpoint Type to Method
Set classname to java.io.EOFException, for convenience click the All Methods for given class checkbox. (otherwise you would have to set different breakpoints for the different constructors)
Choose Run -> Debug Project (Ctrl+F5) to debug your program. It should stop when the EOFException is created.
Go to Window -> Debugging -> Call Stack to see where it was called from.

Categories