Hi Tomas,

Sorry, it's not clear what are you trying to do, can you please specify? Are you working on custom plugin?



i am sorry. I am developing plugin, where i paint additional text at the end of some lines (line extensions). For this, i am using EditorLinePainter.class and i am overriding getLineExtensions method to paint a text.

And i would like to write unittest for this functionality, to check if the text was painted at specified line.

I would expect testHighlighting() from  CodeInsightTestFixture.class would run my plugin code and paint the text or something similar. But it doesnt work and i didnt find any function to do that. 

How can i test EditorLinePainter?




Hello Tomas,

If possible please describe in more details what are you planning to test. Thank you


Hi Olga,

of course. So firsly i will describe functionality of my plugin. As i said i have a class which extend from:

In this class i override method getLineExtensions(). Inside the method, i create instances of the object:
I return collection of these instances.

This way i am able to paint custom text at different lines to different files in editor. Example:

The red text (its not clickable and cannot be edited, its just painted there) is result. And i want to unit test this.



Hello Tomas, Sorry for a long time to reply. Unfortunately, IntelliJ Platform does not provide a way to unit test Line Extensions. They are rendered as graphical elements, not the text, and you may test them using some image comparison tool.

Thank you for answer. So how could i retrieve those 'rendered graphical elements'/pictures in my unittest? So i can compare then with expected ones.


For example, I can suggest a tool which our QA Automation Team is using: https://mvnrepository.com/artifact/ru.yandex.qatools.ashot


If read about that tool here:
It looks like it can retrieve graphical elements from websites. But i need to retrieve graphical elements generated using getLineExtensions() function. Maybe i am missing something. Could you tell me more how could i use that tool to compare line extensions graphical elements?


If i understand it correctly, i can use this class to compare two images. But the problem is, i dont know how to retrieve 'actual' image. By that, i mean, i dont know how to automatically retrieve line extention image in unittest of my plugin.


You can make a screenshot, and then compare it with the expected one using ImageDiffer#makeDiff.

For that, you may use tools from java.awt package: https://stackoverflow.com/questions/4490454/how-to-take-a-screenshot-in-java


Please sign in to leave a comment.