Testing¶
Language Namespace : nl.f1re.testing
This language contains utility classes to help with writing tests and
a concept fileNodeEditor to get access to the (IntelliJ) editor of the testcase (MPSFileNodeEditor).
All helper classes assume no read/write access to the model.
When a class needs an editor cell, you can pass it, for example, through
editor component.findNodeCell(node)editor component.getSelectedCell()
If you are in a nodes test case and not an editor test case, you need an editor component first:
Asserts¶
void assertFails(ThrowableRunnable
| Successful assert | |
|---|---|
| Failing assert | |
|---|---|
EditorCellTestHelper¶
This class contains methods that help with editor cells. An EditorCell must be passed as an argument.
- node<> getLinkedNode() - returns the referenced node of a hyperlink.
- void focus() - change the selection to the cell and also set the focus.
- EditorCell_Collection getToolTipCell() - returns the root cell of the tooltip if the cell has a tooltip.
EditorComponentTestHelper¶
This class contains methods that help with manipulating the editor. An EditorComponent must be passed as an argument.
-
void increaseUIScale() - increase the editor scale by 20% and rebuild the editor afterwards
Example: Increase the editor scaling (needs the reflection language) -
void decreaseUIScale() - decrease the editor scale by 20% and rebuild the editor afterwards
Example: Increase the editor scaling (needs the reflection language) -
void resetUIScale() - reset the editor scale and rebuild the editor afterwards
Example: Increase the editor scaling (needs the reflection language) -
ContextAssistantManager openContextAssistant() - Opens the context assistant in the editor.
IntentionTester¶
This class contains methods to work with intentions. An EditorContext must be passed as an argument as well as the information if surround intentions should be found.
- Pair
getSingleMatchingIntention(node, intentionCondition) - returns a single intention that can be applied for the node that matches a condition
PlatformTestHelper¶
This classes contains utility methods for testing the IntelliJ platform. An jetbrains.mps.project.Project must be passed as an argument.
- void withClipboardData(action, data) - temporarily set the clipboard data to a certain string and execute an action
| Example: Paste the text 'test' into the MPS editor. | |
|---|---|
- void findNotification(triggerNotification,action,timeout) - create a new notification and wait a certain time for it to appear
-
void withPowerSaveModelEnabled(code) - execute code while the power save mode enabled.#
-
void assertHasFatalError(errorText) - assert that the IDE threw an exception in the lower right corner.
| Example: Assert a fatal error | |
|---|---|
ProjectTestHelper¶
This class contains helper methods that needs a project as an argument. An jetbrains.mps.project.Project must be passed as an argument to this class.
- void reloadModule(module) - reload a module
- void reloadModules(modules) - reload a list of modules
- void reloadAll() - reload all modules
| Example: Reload a module | |
|---|---|
-
list
getOpenEditors() - returns a list of opened editors or an empty list instead. -
MPSFileNodeEditor getActiveEditor() - returns the currently selected opened editor.
-
void closeOpenEditors() - close all open editors
-
void assertEditorNotBroken(node) - assert that the editor for the node can be created. It catches exception where an editor cell can’t be created.
TypesystemTestUtil¶
This class contains helper methods for testing the typesystem.
- Duration measureTypesystemPerformance(model) - tests how long it takes to execute all typesystem checks for a model.