Complete example Custom Validator Test? [message #758749] |
Thu, 24 November 2011 13:20 |
Scott Finnie Messages: 94 Registered: October 2011 |
Member |
|
|
Trying to write some custom validations test first. I looked at example code in the docs - which is useful but doesn't include imports or really show how to create sample models to test against. I tried the sample projects but none seems to include tests for custom validation. I'm not familiar with the ecore API which doesn't help.
Would appreciate if someone could point me to a complete example of a test file. So far I have the basics in place I think (imports, setup):
package org.domainmodels.Ooa.unittest;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.domainmodels.OoaInjectorProvider;
import org.domainmodels.OoaStandaloneSetup;
import org.domainmodels.validation.OoaJavaValidator;
import org.eclipse.xtext.junit4.InjectWith;
import org.eclipselabs.xtext.utils.unittesting.XtextRunner2;
import org.eclipse.xtext.junit.AbstractXtextTests;
import org.eclipse.xtext.junit.validation.ValidatorTester;
@RunWith(XtextRunner2.class)
@InjectWith(OoaInjectorProvider.class)
public class TestOoaCustomValidation extends AbstractXtextTests {
private ValidatorTester<OoaJavaValidator> tester;
@Override
public void setUp() {
try {
with(OoaStandaloneSetup.class);
OoaJavaValidator validator = get(OoaJavaValidator.class);
tester = new ValidatorTester<OoaJavaValidator>(validator, getInjector());
} catch(Exception e) {
System.out.println(e);
}
}
@Test
public void testClassMustHaveAtLeastOneIdentifier(){
fail();
}
}
Thanks.
[Updated on: Thu, 24 November 2011 13:21] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02237 seconds