Просмотр исходного кода

Added test that checks all test models for diagnostics

Andreas Mülder 12 лет назад
Родитель
Сommit
a2ceeeb82d

+ 1 - 1
test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/AllTests.java

@@ -23,7 +23,7 @@ import org.junit.runners.Suite.SuiteClasses;
 		TypeInferrerTest.class, 
 		STextJavaValidatorTest.class, 
 		StextParserRuleTest.class,
-		TestModelsContainErrors.class 
+		TestModelsContainErrorsTest.class 
 		})
 public class AllTests {
 

+ 82 - 0
test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/TestModelsContainErrorsTest.java

@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) 2013 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.model.stext.test;
+
+import java.util.List;
+
+import org.eclipse.xtext.junit4.validation.AssertableDiagnostics;
+import org.eclipse.xtext.junit4.validation.ValidatorTester;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.stext.ui.internal.STextActivator;
+import org.yakindu.sct.model.stext.validation.STextJavaValidator;
+import org.yakindu.sct.test.models.SCTUnitTestModels;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import static org.junit.Assert.*;
+
+/**
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+@RunWith(Parameterized.class)
+public class TestModelsContainErrorsTest {
+
+	@Inject
+	private STextJavaValidator validator;
+	@Inject
+	private Injector injector;
+
+	private Statechart statechart;
+
+	private ValidatorTester<STextJavaValidator> tester;
+
+	public TestModelsContainErrorsTest(Statechart statechart) {
+		STextActivator.getInstance().getInjector(STextActivator.ORG_YAKINDU_SCT_MODEL_STEXT_STEXT).injectMembers(this);
+		this.statechart = statechart;
+	}
+
+	@Before
+	public void setup() {
+		tester = new ValidatorTester<STextJavaValidator>(validator, injector);
+	}
+
+	@After
+	public void teardown() {
+		tester = null;
+	}
+
+	@Parameters
+	public static Iterable<Object[]> testData() throws Exception {
+		SCTUnitTestModels models = new SCTUnitTestModels();
+		List<Statechart> all = models.loadAllStatecharts();
+		return Iterables.transform(all, new Function<Statechart, Object[]>() {
+			public Object[] apply(Statechart input) {
+				return new Object[] { input };
+			}
+		});
+	}
+
+	@Test
+	public void testTestModelContainsErrors() throws Exception {
+		AssertableDiagnostics validate = tester.validate(statechart);
+		assertTrue("Testmodel " + statechart.getName() + " contains validation diagnostics",
+				Iterables.size(validate.getAllDiagnostics()) == 0);
+	}
+}