Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Re: using AbstractXtextTests
Re: using AbstractXtextTests [message #637339] Fri, 05 November 2010 02:55
Lorenzo Bettini is currently offline Lorenzo Bettini
Messages: 1119
Registered: July 2009
Senior Member
On 11/04/2010 03:41 PM, Lorenzo Bettini wrote:
> Hi
>
> I started to use AbstractXtextTests for unit tests, and I was trying
> this simple one (where MyDsl is the actual name of my Dsl), and ... is a
> program in my dsl:
>
> public class LinkingTest extends AbstractXtextTests {
>
> @Override
> protected void setUp() throws Exception {
> super.setUp();
> with(MyDslStandaloneSetup.class);
> }
>
> public void testSimple() throws Exception {
> EObject model = getModel("...");
> }
> }
>
> this test fails because a reference in the program (actually to an ecore
> class) cannot be solved... however, if I put the same program string in
> the generated editor the reference is resolved... am I doing something
> wrong when writing the test?
>
> Is getModel method in AbstractXtextTests the right method to use to load
> from a string?
>

Let's see whether I can answer myself: since the reference is to an
ecore class, and since it is run as a unit test, EClass references are
not provided automatically... this is related to Sebastian's answer to
my other thread (inspecting the classes of an EMF model):

"by default we put all EClasses with their simple name into the index
which implies that your expression may refer to any given EClass that
resides in a project which is on the classpath of your model's project."

since it's a unit test, the index is not available, right?

indeed with a customized scope provider it seems to work.

am I right about that?

thanks
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
Previous Topic:Memory consumption
Next Topic:References
Goto Forum:
  


Current Time: Thu May 23 16:03:26 EDT 2013

Powered by FUDForum. Page generated in 0.01384 seconds