
The Hektor icon also lets you activate power save mode that helps conserve battery power by disabling highlighting and auto-popups.

At syntax level you don't get any warnings except when code can't be compiled. It helps you switch highlighting levels: from none to syntax and inspections. Highlighting level and power save modeĪnother useful thing is the Hektor icon located on the status bar.

To run a single inspection by its name just press Shift + Alt + Ctrl + I ( Shift + Alt + Cmd + I for Mac) shortcut or use Analyze → Run Inspection by Name.ħ. Sometimes it may be a better solution than disabling the inspection for an entire project. When you don’t want warnings from this or that inspection for a specific statement or method, you can simply suppress them by pressing the right arrow on a quick-fix. Just press Alt + Enter and choose a quick-fix. Most inspections not only tell you where a problem is, but provide quick-fixes to deal with them right away. To get complete report with the inspection results for an entire project, use the Analyze → Inspect Code command. You can configure the severity of the problems through which the F2 key navigates in the Settings → Editor and tell it, for example, to always jump to the most serious issue in a file. Press F2 to go to the next problem and Shift+F2 to go to the previous one. The editor lets you quickly navigate between the highlighted problems via keyboard shortcuts. Inspections that are too complex to be run on on-the-fly are available when you perform code analysis for the entire project via Analyze → Inspect Code menu, or when you run certain inspection by its name via Analyze → Run Inspection by Name. Most of the inspections run on-the-fly and display warnings or errors in the editor immediately as you type. testExpectedException() else if ( elem.Inspections are built-in static code analysis tools that help you find probable bugs, locate dead code, detect performance issues and improve the overall code structure. Given below is a very simple test that expects NumberFormatException to be thrown when the supplied code block is executed. Expected exception is thrown from the test If the code block throws an exception of a class that is a subtype of the expectedType exception only then the assertThrows() will PASS.įor example, if we are expecting IllegalArgumentException and the test throws NumberFormatException then also the test will PASS because NumberFormatException extends IllegalArgumentException class.Īlso, if we pass Exception.class as the expected exception type, any exception thrown from the executable block will make the assertion PASS since Exception is the super-type for all exceptions.

Static T assertThrows(Class expectedType, Executable executable, String message)

static T assertThrows(Class expectedType, Executable executable) It is an overloaded method and takes the following parameters. The assertThrows() method asserts that execution of the supplied executable block or lambda expression throws an exception of the expectedType. Exception thrown is of a different type or No exception is thrownġ.
