Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » JUnit testing and Sirius
JUnit testing and Sirius [message #1802948] Tue, 19 February 2019 13:37 Go to next message
Lutz Wrage is currently offline Lutz WrageFriend
Messages: 141
Registered: July 2009
Senior Member
We have a diagram editor based on Sirius. We now want to write JUnit tests but have a hard time finding introductory examples and documentation. We fond the tests in the Sirius git repository, but without further explanation it is hard to understand what is going on and why. Are there any other resources available that we missed? Maybe we didn't look in the right places.

Also, the tests in the git repo seem to be written as JUnit3 tests. Is there any support available or planned for testing with JUnit5?

Thanks!
Re: JUnit testing and Sirius [message #1802987 is a reply to message #1802948] Wed, 20 February 2019 09:48 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 249
Registered: June 2017
Senior Member
Hi,

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.


Regards,


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/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 Go to previous message
Tjalling Ran is currently offline Tjalling RanFriend
Messages: 4
Registered: February 2019
Junior Member
Hi Lutz,

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

Previous Topic:Creating an updatesite with examples
Next Topic:Custom layout for border nodes
Goto Forum:
  


Current Time: Sat Aug 24 11:02:19 GMT 2019

Powered by FUDForum. Page generated in 0.01905 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top