Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » testing with ValidationTestHelper
testing with ValidationTestHelper [message #758810] Thu, 24 November 2011 15:48 Go to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1762
Registered: July 2009
Location: Firenze, Italy
Senior Member
Hi

I was doing some junit tests in an xtend2 class and I'm using

@Inject
ParseHelper<XtypesTypeSystem> parser

@Inject extension ValidationTestHelper

however, the ValidationTestHelper does not seem to find all the errors
in the source file, in particular it does not run
org.eclipse.xtext.validation.NamesAreUniqueValidator (which I enabled,
and works in the new runtime eclipse instance)

is it the expected behavior?

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


Re: testing with ValidationTestHelper [message #758829 is a reply to message #758810] Thu, 24 November 2011 16:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13427
Registered: July 2009
Senior Member
Hi,

i cannot reproduce this

@ComposedChecks(validators = { NamesAreUniqueValidator.class })
public class MyDslJavaValidator extends AbstractMyDslJavaValidator {


}


@RunWith(XtextRunner.class)
@InjectWith(MyDslInjectorProvider.class)
public class Test extends AbstractXtextTests {

	@Inject
	MyDslJavaValidator validator;

	@Inject
	Injector injector;

	@Inject
	ParseHelper<Model> parser;

	@org.junit.Test
	public void TestIt() throws Exception {
		ValidatorTester<MyDslJavaValidator> tester = new ValidatorTester<MyDslJavaValidator>(validator, injector);
		System.out.println(tester.validate(parser.parse("Hello You! Hello You!")));
	}
}


~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: testing with ValidationTestHelper [message #758853 is a reply to message #758829] Thu, 24 November 2011 18:07 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
Christian, normally the @ComposedChecks annotation is on the AbstractMyDslJavaValidator and that makes a difference. If you want to be sure to catch all errors and warnings in precisely the same manner as in the actual plug-in, use org.eclipse.emf.ecore.util.Diagnostician which makes use of the EMF Validator framework while the ValidatorTester doesn't necessarily.

Re: testing with ValidationTestHelper [message #758938 is a reply to message #758829] Fri, 25 November 2011 11:00 Go to previous message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1762
Registered: July 2009
Location: Firenze, Italy
Senior Member
Thanks! Then I need to use ValidatorTester (which I've already used in
the past); I thought I could do the same with ValidationTestHelper :)

On 11/24/2011 05:24 PM, Christian Dietrich wrote:
> Hi,
>
> i cannot reproduce this
>
> @ComposedChecks(validators = { NamesAreUniqueValidator.class })
> public class MyDslJavaValidator extends AbstractMyDslJavaValidator {
>
>
> }
>
> @RunWith(XtextRunner.class)
> @InjectWith(MyDslInjectorProvider.class)
> public class Test extends AbstractXtextTests {
>
> @Inject
> MyDslJavaValidator validator;
>
> @Inject
> Injector injector;
>
> @Inject
> ParseHelper<Model> parser;
>
> @org.junit.Test
> public void TestIt() throws Exception {
> ValidatorTester<MyDslJavaValidator> tester = new
> ValidatorTester<MyDslJavaValidator>(validator, injector);
> System.out.println(tester.validate(parser.parse("Hello You! Hello You!")));
> }
> }
>
> ~Christian


--
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:Xtend function definition syntax
Next Topic:[Xtext 2.1] Implementing a custom post build step
Goto Forum:
  


Current Time: Wed Apr 08 19:27:53 GMT 2020

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

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

Back to the top