Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » ValidateTestHelper.asserError arguments
ValidateTestHelper.asserError arguments [message #1753312] Fri, 03 February 2017 16:58 Go to next message
Greg Lusk is currently offline Greg LuskFriend
Messages: 32
Registered: February 2017
Location: USA
I am fairly new to Xtext, and am trying to write a unit test to assert that an error occurs in deliberately bad syntax. I'm not exactly sure how to pass the second (EClass) argument to the function call. Can anyone post an example and explain how to specify a value for this argument?

Re: ValidateTestHelper.asserError arguments [message #1753560 is a reply to message #1753312] Tue, 07 February 2017 17:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 11967
Registered: July 2009
Senior Member
Can you be more specific about the kind of error / validation you want to test

Need professional support for Xtext, Xpand, EMF?
Go to:
Twitter : @chrdietrich
Blog :
Re: ValidateTestHelper.asserError arguments [message #1753648 is a reply to message #1753312] Wed, 08 February 2017 13:15 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 757
Registered: July 2009
Location: Hamburg
Senior Member
In Xtext, an EClass is the type of an element in your AST. The 'E' stands for Ecore, which offers a bit higher-level description of types than Java.
If you use a generated Ecore model (that's the default), the EClasses are defined by the rules in your grammar, e.g.

grammar ...

generate myEcore "http:..." // will result in an EPackage 'myEcore'

Foo: // will result in an EClass 'Foo'
'foo' name=ID; // will result in an EAttribute 'name'

Will result in an EClass 'Foo' with and EAttribute 'name' of type 'EString'.
Once you run the workflow, the code generator will derive an Ecore model with the EClasses from your grammar. Then it will run the EMF code generator to generate Java classes from the Ecore model.

If you need to access an EClass, e.g. to pass it to the ValidationTestHelper, you find it as a singleton in the generated EPackage class. In our case
If you have an element of the AST in your hands, use

Get professional support from the Xtext committers at
Previous Topic:Troubles With Parsing Numbers
Next Topic:Adding definition in global scope provider
Goto Forum:

Current Time: Thu May 24 23:42:14 GMT 2018

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

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

Back to the top