Commit 8a521efd authored by Kisslinger's avatar Kisslinger
Browse files

Using now TestingModelElementFactory

parent bb3dcab5
......@@ -17,25 +17,28 @@ $Id$
+--------------------------------------------------------------------------*/
package test.org.fortiss.af3.testing.model;
import static org.fortiss.af3.testing.utils.TestingModelElementFactory.createTestCase;
import static org.fortiss.af3.testing.utils.TestingModelElementFactory.createTestInput;
import static org.fortiss.af3.testing.utils.TestingModelElementFactory.createTestOutput;
import static org.fortiss.af3.testing.utils.TestingModelElementFactory.createTestStep;
import static org.fortiss.af3.testing.utils.TestingModelElementFactory.createTestSuite;
import org.fortiss.af3.expression.language.evaluation.NoVal;
import org.fortiss.af3.expression.model.terms.impl.IntConstStaticImpl;
import org.fortiss.af3.project.model.typesystem.ITerm;
import org.fortiss.af3.testing.model.TestCase;
import org.fortiss.af3.testing.model.TestInput;
import org.fortiss.af3.testing.model.TestOutput;
import org.fortiss.af3.testing.model.TestStep;
import org.fortiss.af3.testing.model.TestSuite;
import org.fortiss.af3.testing.model.TestingModelFactory;
import test.org.fortiss.af3.state.model.StateBasedCounterTestModel;
/**
* Programmatic setup of the state-based Counter test model extended with a test suite.
*
* @author bernhard
* @author kisslinger
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 1183AD265FE53EF71CBA7DB9AFAE015D
* @ConQAT.Rating YELLOW Hash: 4540C73C718A7CF5C6F9DC5C892DED3A
*/
public class TestCaseCounterTestModel extends StateBasedCounterTestModel {
......@@ -48,7 +51,7 @@ public class TestCaseCounterTestModel extends StateBasedCounterTestModel {
@Override
public void setupModel() {
super.setupModel();
createTestSuite();
createTestSuiteForTest();
// we don't want the feedback port in this test
counterComponent.getConnectorsList().remove(this.feedbackInputPort);
}
......@@ -56,14 +59,11 @@ public class TestCaseCounterTestModel extends StateBasedCounterTestModel {
/**
* Creates a test suite for the test model. The test suite contains one single test case
*/
private void createTestSuite() {
// TODO: this create methods should go into or use utility class TestingModelElementFactory
testsuite = TestingModelFactory.eINSTANCE.createTestSuite();
testsuite.getInputPortsList().add(counterComponent.getInputPorts().get(0));
testsuite.getOutputPortsList().add(counterComponent.getOutputPorts().get(0));
private void createTestSuiteForTest() {
testCase = TestingModelFactory.eINSTANCE.createTestCase();
testsuite.getTestCasesList().add(testCase);
testsuite = createTestSuite("", counterComponent);
counterComponent.getSpecificationsList().add(testsuite);
testCase = createTestCase(testsuite);
addTestStep(testCase, IntConstStaticImpl.create(0), NoVal.NOVAL.toITerm());
addTestStep(testCase, IntConstStaticImpl.create(1), NoVal.NOVAL.toITerm());
......@@ -71,25 +71,15 @@ public class TestCaseCounterTestModel extends StateBasedCounterTestModel {
addTestStep(testCase, IntConstStaticImpl.create(1), IntConstStaticImpl.create(-1));
addTestStep(testCase, IntConstStaticImpl.create(0), IntConstStaticImpl.create(0));
addTestStep(testCase, IntConstStaticImpl.create(1), IntConstStaticImpl.create(-1));
counterComponent.getSpecificationsList().add(testsuite);
}
/**
* Adds one test step with the specified input and output values to the specified testCase
*/
private void addTestStep(TestCase testCase, ITerm input, ITerm output) {
TestStep testStep = TestingModelFactory.eINSTANCE.createTestStep();
TestInput tInput = TestingModelFactory.eINSTANCE.createTestInput();
tInput.setValue(input);
TestOutput tOutput = TestingModelFactory.eINSTANCE.createTestOutput();
tOutput.setExpectedValue(output);
testStep.getInputsList().add(tInput);
testStep.getOutputsList().add(tOutput);
testCase.getTestStepsList().add(testStep);
TestStep testStep = createTestStep(testCase);
createTestInput(testStep, input);
createTestOutput(testStep, output, null);
}
/** Returns testSuite. */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment