Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to unit test global scoping
How to unit test global scoping [message #861118] Sat, 28 April 2012 11:33 Go to next message
Felix Feisst is currently offline Felix FeisstFriend
Messages: 20
Registered: February 2012
Location: Germany
Junior Member
Hi,

for my local scope provider, I easily provided unit tests by building partial EMF-ASTs
and calling getScope(..) with the corresponding element.

For my global scope provider I want to do the same. However, i wonder how to put an IEObjectDescription onto the index programatically.

I'm looking forward to any ideas or hints.

Regards,
Felix
Re: How to unit test global scoping [message #861178 is a reply to message #861118] Sat, 28 April 2012 12:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

do you do any customization to index? if not what about binding a complete mock for the test.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sat, 28 April 2012 12:17]

Report message to a moderator

Re: How to unit test global scoping [message #865244 is a reply to message #861178] Mon, 30 April 2012 09:58 Go to previous messageGo to next message
Felix Feisst is currently offline Felix FeisstFriend
Messages: 20
Registered: February 2012
Location: Germany
Junior Member
No, i don't do any customization to index.
How can i create the mock for the test?
I'm not familiar with the index and don't know, how to put an IEObject Descripton onto the index.

Felix
Re: How to unit test global scoping [message #865293 is a reply to message #865244] Mon, 30 April 2012 10:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

you have basically two choices:
(1) use the std behaviour without any mocks => simply take care the eobjects that should be in the global scope
have to reside in the same resourceset as test object you test the scoping on.
(a) create a resourceset
(b) create a resource in the resourceset and add the objects in the global scope to it
(c) create a resource in the resourceset and add the test object there

(2) you bind a IGlobalScopeProvider in a special runtime module + setup you use in the test
the global scopeprovider returns a scope. use e.g. a simple scope

btw if you dont do any customizations to the global scope, why do you want to test it at all?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to unit test global scoping [message #867707 is a reply to message #865293] Tue, 01 May 2012 12:43 Go to previous messageGo to next message
Felix Feisst is currently offline Felix FeisstFriend
Messages: 20
Registered: February 2012
Location: Germany
Junior Member
Well, I misunderstood you earlier, I do some changes to the index: I provide an own implementation of IDefaultResourceDescriptionStrategy (btw, why is there a Default in the interface name?) to handle which EObjects are exported.

When I do create a ResourceSet (with ResourceSetImpl) for the tests, how does the framework know of my own ResourceSet or does the creation of ResourceSetImpl take care of that?

A second thing is, i want to check that a declared entity is unique on the index. For that reason I inject my Validator with an instance of IResourceDescriptions (note the plural 's') and calling the "getExportedObjects(..)" method. Running the plugin, this works fine. However, running the tests, an exception is thrown when invoking that method. I guess it has something to do with the index and ResourceSet, too?

Thanks so far,
Felix
Re: How to unit test global scoping [message #867730 is a reply to message #867707] Tue, 01 May 2012 12:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

in general the "index" works different standalone and in ui.
standalone it is resourcesetbased. in ui it is "container based" = project based.

please use an injector to create a ResourceSet.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to unit test global scoping [message #867753 is a reply to message #867730] Tue, 01 May 2012 13:10 Go to previous messageGo to next message
Felix Feisst is currently offline Felix FeisstFriend
Messages: 20
Registered: February 2012
Location: Germany
Junior Member
How can I Inject a ResourceSet? Is IResourceSetProvider the correct class (but that is only available in the ui project and how to retrieve the IProject instance)?

Sorry, but I didn't find documentation for this kind of stuff.
Re: How to unit test global scoping [message #867769 is a reply to message #867753] Tue, 01 May 2012 13:19 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi it is meant for use in UI so use Provider<ResourceSet> instead

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:extend the editor with popup menu
Next Topic:Null pointer when serializing cross references
Goto Forum:
  


Current Time: Thu Apr 25 14:08:02 GMT 2024

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

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

Back to the top