Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » How to unit test diagram related operations ?
How to unit test diagram related operations ? [message #1817442] Fri, 22 November 2019 09:13 Go to next message
Mehdi Belatrous is currently offline Mehdi BelatrousFriend
Messages: 6
Registered: September 2019
Junior Member
Hi everyone,
I'm currently trying to test (with JUnit) a Capella viewpoint code. For example, I want to test below method.
ExecutionManager manager = Utils.getExecutionManager(eObject);
manager.execute(new AbstractReadWriteCommand(){
	@Override
	public void run() {
		componentExchange.getAppliedPropertyValues().add(except);
		resource.getContents().add((EObject) except);
	}
});


However this test will fail because ExecutionManager is null since no Sirius session is loaded and no diagram is open. Searching Eclipse Sirius forum I found this topic advising to make test class extend SiriusDiagramTestCase. So I installed Sirius test suite and did so. However though I understand that setup and genericSetup method are the keys, I dont know how to properly use them (mine just hang up indefinitly) and I searched a bit in Sirius tests but could not find suitable code.

Can someone point me in the right direction ? Thanks in advance for any help.
Re: How to unit test diagram related operations ? [message #1817585 is a reply to message #1817442] Tue, 26 November 2019 09:34 Go to previous messageGo to next message
Florian Barbin is currently offline Florian BarbinFriend
Messages: 252
Registered: August 2010
Senior Member
Hi,

Capella has its own JUnit test framework where most of the tests inherit from org.polarsys.capella.test.framework.api.BasicTestCase. (directly or indirectly). The capella framework will offer you specific API since the Sirius test framework is more generic.

You should take a look in the Capella repository: https://git.polarsys.org/c/capella/capella.git/

Regards,

Florian
Re: How to unit test diagram related operations ? [message #1818037 is a reply to message #1817585] Wed, 04 December 2019 15:01 Go to previous message
Mehdi Belatrous is currently offline Mehdi BelatrousFriend
Messages: 6
Registered: September 2019
Junior Member
Hello Florian and thank you for your indications. However digging through Capella Test Suite just got me even more confused. For example I see that the common testing pattern seems to create some test cases which extend the BasicTestCase class, register these cases in some test suites, all this inside an Eclipse Plugin. I suppose that these suites are called using an Eclipse Application Run/Debug configuration which loads a Capella instance. So my question is :

Did I did get this right and is this structure mandatory ? (TestCase + TestSuite + Eclipse Plugin + Eclipse Application). Because for non-diagram operation I could run my test using JUnit debug configurations.

Should all tests be in a dedicated plugin containing a "model" folder with .aird and .melodymeller files ?

Thanks for your help.

[Updated on: Wed, 04 December 2019 15:05]

Report message to a moderator

Previous Topic:Sirius 0.9 install problem on Kepler
Next Topic:How to add SessionWrapper/ViewHelper extensions to handle custom tree elements
Goto Forum:
  


Current Time: Sun Nov 29 00:13:20 GMT 2020

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

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

Back to the top