6

Why won't IntelliJ IDEA stop in debug mode when an assertion is triggered? I get a java.lang.AssertionError to console, but the running code doesn't pause at it as it is supposed to. Here are my exception breakpoints settings:

http://i.imgur.com/kiMwLfb.png

2
  • try to change 'thread' radio to 'all' Commented Mar 30, 2014 at 8:13
  • @Rafik991 No, that's not the cause of the issue. Commented Mar 30, 2014 at 9:20

3 Answers 3

6

I found out that somehow debugger doesn't stop on assertions when running tests, but it does stop when running other code. The code I was trying to make stop on a failed assertion in debug mode was a test. That seems to be the issue, but I don't understand why would IDE behave that way.

Sign up to request clarification or add additional context in comments.

1 Comment

Still encountering this issue.
5

Open source code of AssertionError and put a breakpoint on the constructor it will stop. enter image description here

Comments

0

What worked for me is explicitly adding and enabling the java.lang.AssertionError in the Java Exception Breakpoints category in the Breakpoints settings window.

Go to Run -> View Breakpoints, in the Breakpoints window click the plus + from the top left corner. From the drop down list, select Java Exception Breakpoints

In the Enter Exception class dialog, type java.lang.AssertionError and click OK

The java.lang.AssertionError will now show up in the Breakpoints window under the Java Exception Breakpoints category. Tick the box to enable it and further edit options for this exception. Click Done.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.