|
Re: JUnit + ResourceSetListener [message #1837236 is a reply to message #1837232] |
Mon, 25 January 2021 16:41   |
|
Hi, Grischa,
If you're testing extensions of Papyrus, you may find it useful to employ the org.eclipse.papyrus.junit.utils.rules.ModelSetFixture class in your tests. This creates a complete (as complete as you need it) ModelSet for consistency with the Papyrus editing environment. Then your tests can drive changes in the resources in this fixture, and the TransactionalEditingDomain that manages the ModelSet will send the events that your listeners need.
This may be the easiest strategy to get working, because it provides all of the usual machinery and you can use Papyrus to create models to drive your tests.
Alternatively, mocking frameworks like PowerMock may be able to mock classes such as ResourceSetChangeEvent so that you can supply your tests with only the absolute minimum required of the API. I have not tried this in my own tests but I don't see why it shouldn't work. Mocking frameworks generally employ low-level JVM APIs to constructs objects, etc. so that assertions like the one giving you the IllegalArgumentException would be bypassed.
HTH,
Christian
|
|
|
|
Powered by
FUDForum. Page generated in 0.02283 seconds