Home » Modeling » TMF (Xtext) » problems when unit testing the content assist (which uses the Index)
problems when unit testing the content assist (which uses the Index) [message #732044] |
Mon, 03 October 2011 19:07 |
|
Hi
starting from this post
http://www.eclipse.org/forums/index.php/mv/msg/227257/716792/
I managed to start testing my content assist; however in a specific
case, my content assist uses the index to build the proposals. When
trying the editor in the new eclipse instance the content assist
correctly works, but not when doing the (plugin) unit test... in
particular, while debugging I see that the last instruction of my method
protected Collection<IEObjectDescription> getAllVisibleObjectsByType(
EObject context, EClass type) {
Resource eResource = context.eResource();
IResourceDescriptions index = resourceDescriptionsProvider
.getResourceDescriptions(eResource);
IResourceDescription resourceDescription = index
.getResourceDescription(eResource.getURI());
returns a null IResourceDescription
can this issue be dealt with, or isn't the index not available when
using AbstractContentAssistProcessorTest?
thanks in advance
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
| | | | | | | |
Re: problems when unit testing the content assist (which uses the Index) [message #732093 is a reply to message #732092] |
Mon, 03 October 2011 21:41 |
|
Hi,
no i guess one wont changed this since in ui you have usually this
project state. thus id still try to give xtext.ui what it wants:
a project.
~Christian
Am 03.10.2011 23:33, schrieb Lorenzo Bettini:
> On 10/03/2011 11:14 PM, Christian Dietrich wrote:
>> No,
>>
>> just local scoping will work. global (index based) wont
>>
>> ~Christian
>
> thus global scoping works in a non-ui test environment because the
> (default generated) runtime module has this binding
>
> public Class<? extends
> org.eclipse.xtext.resource.containers.IAllContainersState.Provider>
> bindIAllContainersState$Provider() {
> return
> org.eclipse.xtext.resource.containers.ResourceSetBasedAllContainersStateProvider.class;
>
> }
>
> while the ui module has this one
>
> public
> com.google.inject.Provider<org.eclipse.xtext.resource.containers.IAllContainersState>
> provideIAllContainersState() {
> return org.eclipse.xtext.ui.shared.Access.getJavaProjectsState();
> }
>
> it could be enough to use the same binding of the non-ui runtime module
> in my derived AbstractContentAssistProcessorTest, couldn't it?
>
> cheers
> Lorenzo
>
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Re: problems when unit testing the content assist (which uses the Index) [message #732094 is a reply to message #732087] |
Mon, 03 October 2011 21:52 |
|
On 10/03/2011 11:39 PM, Christian Dietrich wrote:
> Hi,
>
> there is still the problem that the index standalone is still totaly
> different from the one in ui.
> thus you have to handle this in the test. a resourceset based index wont
> work.
> thus i'd still try to create the project manually and take care the uri
> of your test file
> points to that project (by hacking
> org.eclipse.xtext.junit.AbstractXtextTests.doGetResource(InputStream, URI))
>
it is quite clear how to create the project and the test file (using the
utility provided by xtext.junit.ui), but by hacking do you mean
something like the following?
1. override AbstractXtextTests.doGetResource(InputStream, URI)
2. in the overridden version ignore the passed URI and always use the
(platform) URI pointing to the created test file in the created project
but still I wouldn't be able to use the builder facilities, would I? I
mean build the program string by using append and then assertText?
cheers
Lorenzo
> I know the AbstractTests Class is crappy regarding this ;)
--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
HOME: http://www.lorenzobettini.it
TDD Book: https://leanpub.com/tdd-buildautomation-ci
Xtext Book: https://www.packtpub.com/application-development/implementing-domain-specific-languages-xtext-and-xtend-second-edition
|
|
|
Re: problems when unit testing the content assist (which uses the Index) [message #732095 is a reply to message #732094] |
Mon, 03 October 2011 21:55 |
|
No,
the test file has not to physically exist.
just its resource uri must point to a file in
the test project.
~Christian
Am 03.10.2011 23:52, schrieb Lorenzo Bettini:
> On 10/03/2011 11:39 PM, Christian Dietrich wrote:
>> Hi,
>>
>> there is still the problem that the index standalone is still totaly
>> different from the one in ui.
>> thus you have to handle this in the test. a resourceset based index wont
>> work.
>> thus i'd still try to create the project manually and take care the uri
>> of your test file
>> points to that project (by hacking
>> org.eclipse.xtext.junit.AbstractXtextTests.doGetResource(InputStream,
>> URI))
>>
>
> it is quite clear how to create the project and the test file (using the
> utility provided by xtext.junit.ui), but by hacking do you mean
> something like the following?
>
> 1. override AbstractXtextTests.doGetResource(InputStream, URI)
> 2. in the overridden version ignore the passed URI and always use the
> (platform) URI pointing to the created test file in the created project
>
> but still I wouldn't be able to use the builder facilities, would I? I
> mean build the program string by using append and then assertText?
>
> cheers
> Lorenzo
>
>> I know the AbstractTests Class is crappy regarding this ;)
>
>
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
Goto Forum:
Current Time: Fri Apr 19 19:14:15 GMT 2024
Powered by FUDForum. Page generated in 0.04223 seconds
|