What I want: I want to write JUnit tests for my Eclipse editor plug-in. For this I want to set up an instance of my TextEditor
extension. Then I want to set the input of this TextEditor
from a String, so that the content of the String is the input of the editor instance. Then I want to run some tests and assert that the editor marks errors and so on.
Where I fail: I don't know how to set up the input of the editor from a String. The only function the editor has to do so is setInput(IEditorInput input)
, but I don't know how to create an ÌEditorInput
with a String as it's content.
Is there any possibility to do so and, if not, any other way to set the input of the editor to a given String?
You can either create a (workspace) file as Greg suggested or implement a specialized
IEditorInput
and open a text editor with this input.For example: