Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Combine tests and validation
Combine tests and validation [message #988312] Thu, 29 November 2012 11:21 Go to next message
Tommaso De Sica is currently offline Tommaso De Sica
Messages: 128
Registered: March 2012
Location: Italy
Senior Member

I'm newbie in the world of Xtend and Unit Test.
I'm testing my grammar, and I want to write a test which test the validation of it.

Here a simple example:

MyGrammar:
Domainmodel: entities+=Entity* ;

Entity:
'ENTITY' name=ID 'END_ENTITY';


Now suppose I've also inserted this validation rule:
@Check
public void checkNoJack(Entity e){
   if (e.getName().equals("Jack")){
      error("This name is not valid.",null);
   }
}


So, if I try to write:
ENTITY Jack END_ENTITY

I will receive an error.

But, if I try this Xtend test:
@Test
def void example() throws Exception{
   parserHelper.parse("ENTITY Jack END_ENTITY")
}

all will go right.

How can I consider validation rules in my tests?

Very thank you!

[Updated on: Thu, 29 November 2012 14:40]

Report message to a moderator

Re: Combine tests and validation [message #988382 is a reply to message #988312] Thu, 29 November 2012 16:46 Go to previous messageGo to next message
Tommaso De Sica is currently offline Tommaso De Sica
Messages: 128
Registered: March 2012
Location: Italy
Senior Member

Other question:
also this work fine:
@Test
def void example() throws Exception{
   parserHelper.parse("CAUSALWORD Jack OTHER_CASUAL")
}


why?!
Re: Combine tests and validation [message #988507 is a reply to message #988312] Fri, 30 November 2012 10:01 Go to previous message
Tommaso De Sica is currently offline Tommaso De Sica
Messages: 128
Registered: March 2012
Location: Italy
Senior Member

Solved with use of
.parse.assertNoErrors
Previous Topic:How does control/override the sort order of the completion proposals?
Next Topic:Check if a feature matches one among more terminals
Goto Forum:
  


Current Time: Sun Oct 26 06:05:35 GMT 2014

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

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