|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Test Content-Assist withing maven build [message #1705739 is a reply to message #1705727] |
Tue, 18 August 2015 16:46 |
|
Hi,
i isnt that problem to port it
package org.xtext.example.mydsl.tests
import java.io.InputStream
import javax.inject.Inject
import javax.inject.Provider
import org.eclipse.emf.common.util.URI
import org.eclipse.xtext.junit4.InjectWith
import org.eclipse.xtext.junit4.XtextRunner
import org.eclipse.xtext.junit4.ui.util.IResourcesSetupUtil
import org.eclipse.xtext.junit4.ui.util.JavaProjectSetupUtil
import org.eclipse.xtext.resource.XtextResource
import org.eclipse.xtext.resource.XtextResourceSet
import org.eclipse.xtext.ui.XtextProjectHelper
import org.eclipse.xtext.xbase.junit.ui.AbstractContentAssistTest
import org.junit.BeforeClass
import org.junit.Test
import org.junit.runner.RunWith
import org.xtext.example.mydsl.MyDslUiInjectorProvider
@RunWith(typeof(XtextRunner))
@InjectWith(typeof(MyDslUiInjectorProvider))
class ContentAssistTest extends AbstractContentAssistTest {
static val PROJECT_NAME = "contentAssistTest"
@Test def void testImportCompletion() {
newBuilder.append('Hello You from ').assertText('You','Me','There')
}
@BeforeClass
def static void setUp() {
AbstractContentAssistTest.setUp
val project = JavaProjectSetupUtil.findJavaProject(PROJECT_NAME);
IResourcesSetupUtil.addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
IResourcesSetupUtil.addBuilder(project.getProject(), XtextProjectHelper.BUILDER_ID);
IResourcesSetupUtil.createFile(PROJECT_NAME + "/src/dummy.mydsl",
'''
Hello Me!
Hello There!
''');
IResourcesSetupUtil.reallyWaitForAutoBuild();
}
@Inject Provider<XtextResourceSet> resourceSetProvider
override getResourceFor(InputStream stream) {
val set = resourceSetProvider.get()
initializeTypeProvider(set)
val result = set.createResource(URI::createURI("platform:/resource/"+PROJECT_NAME+"/src/Test.mydsl"))
result.load(stream, null)
result as XtextResource
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Test Content-Assist withing maven build [message #1707426 is a reply to message #1705465] |
Fri, 04 September 2015 16:19 |
Moshe Maizels Messages: 20 Registered: August 2015 |
Junior Member |
|
|
Hi,
,I did what you suggested, and it did the job.
Now i have another problem which is caused by the scoping which checks that a resource is a physical file to avoid round-inheritance.
To test the content-assist I inherit the AbstractContentAssistTest
and creating a project with Xtext nature and builder at the background, and in this project I create files as resources which I want to cross-reference in my testing.
But I have a problem with the scoping. In the scoping I check that the resource is a physical file, which was a solution to avoid round-inheritance.
On the other hand, the computeProposals() method creates a resource from the newBuilder.append..... using the AbstractContentAssistTest.getResourceFor() method, and this resource is not a physical file, and thus the scoping check fails.
As for now, I'm avoiding this by creating a Degenerate physical-file for this resource on the Xtext-background project, but this is a bad solution as some of my resources could be very complected.
How can I test cross referencing If the scoping (which first get all relevant resources including the one I'm building with newBuilder.append) and its check is a must (to verify no round inheritance)and it test that the resource is a physical file?
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05564 seconds