IntelliJ Platform Plugin SDK
 
IntelliJ Platform Explorer

Testing Highlighting

Edit pageLast modified: 28 November 2024

When writing plugin tests, a common task is testing various kinds of highlighting (inspections, annotators, parser error highlighting, etc.). The IntelliJ Platform provides a dedicated utility and markup format for this task.

To test the highlighting for the file currently loaded into the in-memory editor, invoke CodeInsightTestFixture.checkHighlighting(). The parameters to the method specify which severities should be taken into account when comparing the results with the expected results: errors are always taken into account, whereas warnings, weak warnings, and infos are optional. To ignore verifying additional highlighting, set parameter ignoreExtraHighlighting to true.

Alternatively, you can use CodeInsightTestFixture.testHighlighting(), which loads a testdata file into the in-memory editor and highlights it as a single operation.

Example: Custom Language Support Tutorial: Testing Annotator