|Re: JUnit testing and Sirius [message #1802987 is a reply to message #1802948]
||Wed, 20 February 2019 09:48
| Pierre Guilet
Registered: June 2017
Sadly there is no current plans to switch to JUnit5.
There is no documentation available excepted the javadoc of the Sirius testing API.
What I recommand is to do SWTBot tests with Sirius API. They will be more easy to do than pure Junit plugin ones. Or even RCPTT tests.
For SWTBot you have the test class API AbstractSiriusSwtBotGefTestCase that you should extend and that provides you with methods to open editors, to execute tools, to retrieve edit parts that are the graphical elements available in your diagram representation.
Then there is no other choice that looking at already existing tests to apprehend the framework usage.
But basically you use copyFileToTestProject(Activator.PLUGIN_ID, DATA_UNIT_DIR, MODEL, SESSION_FILE); to put your model and aird file from which you will be doing your tests.
Then you open your representation that is a diagram or a table or a tree one. with available methods.
Then you test your tools or other kind of things with provided methods also.
Then you verify that it is working by checking changes on graphical elements that are edit parts.
Pierre Guilet - Obeo
Need training or professional services for Sirius?
[Updated on: Wed, 20 February 2019 09:56]
Report message to a moderator
|Re: JUnit testing and Sirius [message #1803122 is a reply to message #1802987]
||Fri, 22 February 2019 18:33
| Tjalling Ran
Registered: February 2019
You can have your JUnit classes extend from SiriusDiagramTestCase, which adds lots of convenience (including data members such as semanticModel and session). We usually use SiriusDiagramTestCase#genericSetup() to set up a session with a model, an .odesign and a .aird file, then go from there. Diagrams from the .aird file can be obtained through getRepresentations(...). Once you have the diagram, you can get nodes and edges, etcetera. Depending on the test, it may sometimes be necessary to have an open editor for a diagram as well, e.g. using DialectUIManager.INSTANCE.openEditor(...).
SiriusDiagramTestCase has a lot of methods for applying tools (such as the ones shown in the palette of your Sirius-based editor, as defined in the .odesign) to manipulate the model. This way, you can e.g. check whether a NodeCreationTool that you specified works as intended.
The API of SiriusDiagramTestCase, combined with the documentation that gives the basics and core classes of programatically using Sirius (see https://www.eclipse.org/sirius/doc/developer/Architecture.html), can get you a long way. Still, there's plenty to figure out by yourself, so it'll take time, especially for the first couple of tests.
Also, there are test support APIs in org.eclipse.sirius.tests.support.api. The main use we've gotten out of that is using org.eclipse.sirius.tests.support.api.TestsUtil.waitUntil(...) to have our tests wait for asynchronous activities to complete.
[Updated on: Fri, 22 February 2019 18:36]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.02170 seconds