Commit e5b5c417 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Remove tests from RCP


Signed-off-by: default avatarAlexander Diewald <Diewi@diewald-net.com>
parent 341a8e20
Pipeline #10437 failed with stages
in 1 minute and 17 seconds
......@@ -3,6 +3,5 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test-src"/>
<classpathentry kind="output" path="build"/>
</classpath>
/*-------------------------------------------------------------------------+
| Copyright 2011 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package test.org.fortiss.af3.rcp.application;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import test.org.fortiss.af3.rcp.application.semantic.alignment.c.CCodeEquivalenceTest;
/**
* Index to all tests.
*
* @author ratiu
*/
// @CodeFormatterOff
@RunWith(Suite.class)
@SuiteClasses({
CCodeEquivalenceTest.class
})
// @CodeFormatterOn
public class AllTests {
// empty class
}
/*-------------------------------------------------------------------------+
| Copyright 2013 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package test.org.fortiss.af3.rcp.application.example;
import static org.junit.Assert.assertTrue;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.forms.finder.SWTFormsBot;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
// Class to be removed since SWTbot will be retired: #1987
/**
* SWTBot Test for Simple Traffic Lights Test Specification Example
*
* @author guven
*/
@RunWith(SWTBotJunit4ClassRunner.class)
public class LoadExampleTest {
/** workbench bot */
private static SWTWorkbenchBot bot;
/** form bot */
private static SWTFormsBot botF;
private boolean flag = false;
private static final int WaitingTime = 1000;
private static final String actionText =
"Load Simple Traffic Lights Test Specification Example";
private static final String SimpleTrafficLightsTestSpecificEx =
"SimpleTrafficLightsTestSpecificExample";
/**
* creates new SWTBot work bench
*/
@BeforeClass
public static void beforeClass() {
// SWTBotPreferences.PLAYBACK_DELAY = 100; //put in for slow playback
SWTBotPreferences.TYPE_INTERVAL = 0; // put in for fast playback
bot = new SWTWorkbenchBot();
botF = new SWTFormsBot();
bot.sleep(WaitingTime);
bot.viewByTitle("Welcome").close();
}
/**
* tests the simple traffic light test example
*
* @throws Exception
*
*/
@Test
public void test() throws Exception {
// Creation of the project
bot.perspectiveByLabel("Modeling").activate();
bot.sleep(WaitingTime);
bot.menu("File").menu("Open AF3 Example").menu(actionText).click();
bot.sleep(WaitingTime);
SWTBotView viewModelNavigator = bot.viewByTitle("Model Navigator");
SWTBotTree treeTestEx = viewModelNavigator.bot().tree();
SWTBotTreeItem treeItemAF3Project = treeTestEx.getAllItems()[0];
treeItemAF3Project.select();
canSave();
SWTBotTreeItem architectureNode = treeItemAF3Project.expand().getNode("TL-Architecture");
SWTBotTreeItem controllerNode = architectureNode.expand().getNode("Controller");
if(controllerNode.expand().getItems().length == 3)
flag = true;
assertTrue(flag);
// fail("Not yet implemented");
}
/** save the changing */
private void canSave() throws Exception {
bot.perspectiveByLabel("Modeling").activate();
bot.sleep(WaitingTime);
bot.menu("File").menu("Save").click();
}
}
<!-- (c) 2017 fortiss GmbH -->
<body>
Base package for tests of the AF3 testing plugins.
</body>
/*-------------------------------------------------------------------------+
| Copyright 2011 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package test.org.fortiss.af3.rcp.application.semantic.alignment.c;
import static org.fortiss.af3.project.utils.ProjectUtils.loadProjectFromPlugin;
import static org.fortiss.af3.testing.method.random.util.RandomSpecificationModelElementFactory.createPortBinding;
import static org.fortiss.af3.testing.method.random.util.RandomSpecificationModelElementFactory.createRandomSpecificationPart;
import static org.fortiss.af3.testing.utils.TestingModelElementFactory.createTestSuiteSpecification;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.findContentElementByNameAndClass;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.conqat.lib.commons.collections.Pair;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.InputPort;
import org.fortiss.af3.expression.model.terms.DoubleConst;
import org.fortiss.af3.project.model.FileProject;
import org.fortiss.af3.rcp.application.AF3ApplicationActivator;
import org.fortiss.af3.testing.extension.data.TestSuiteGenerationException;
import org.fortiss.af3.testing.extension.data.TestSuiteValidationException;
import org.fortiss.af3.testing.method.random.generator.RandomTestSuiteGenerator;
import org.fortiss.af3.testing.method.random.model.RandomSpecificationPart;
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.TestSuiteSpecification;
import org.fortiss.af3.testing.validator.platform.generic.GenericGCCPlatformTestSuiteValidator;
import org.fortiss.tooling.kernel.service.ICommandStackService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
/**
* Tests for the C code equivalence.
*
* @author mou
*/
@RunWith(Parameterized.class)
public class CCodeEquivalenceTest {
/** The test-data area. */
private static final int TEST_CASES_NUM = 10;
/** The test-case to be used. */
private TestCase testCase;
/** The tested project. */
private FileProject project;
/** Constructor. */
public CCodeEquivalenceTest(Pair<FileProject, TestCase> pair) {
this.project = pair.getFirst();
this.testCase = pair.getSecond();
}
/**
* Test data.
*
* @throws InterruptedException
*/
@Parameters
public static Collection<Pair<FileProject, TestCase>[]> testDataCollection()
throws TestSuiteGenerationException, TestSuiteValidationException, InterruptedException {
// @CodeFormatterOff
String[][] fileNamesAndComponents = {
new String[] {"platform:/plugin/org.fortiss.af3.rcp.application/test-data/SimpleTrafficLightsExample.af3_23", "Controller"}
};
// @CodeFormatterOn
List<Pair<FileProject, TestCase>[]> testData =
new ArrayList<Pair<FileProject, TestCase>[]>();
// summarize all the FileProject TestCase pairs for all files and them components
for(String[] fileNameAndComponent : fileNamesAndComponents) {
// pack FileProjet TestCase pair in a one element array and then add it to the testData
// list
for(Pair<FileProject, TestCase> projectTestCasePair : collectTestCasesForProject(
fileNameAndComponent[0], fileNameAndComponent[1])) {
@SuppressWarnings("unchecked") Pair<FileProject, TestCase>[] projectTestCasePairArray =
new Pair[1];
projectTestCasePairArray[0] = projectTestCasePair;
testData.add(projectTestCasePairArray);
}
}
return testData;
}
/** */
static TestSuiteSpecification spec;
/** */
static RandomSpecificationPart rsp;
/**
* Generates the tests for a project.
*
* @param fileName
* the name of to tested project
* @param componentName
* the name of to tested component
* @throws TestSuiteGenerationException
* @throws TestSuiteValidationException
* @return collection of project test case pair
* @throws InterruptedException
*/
private static Collection<Pair<FileProject, TestCase>> collectTestCasesForProject(
String fileName, String componentName) throws TestSuiteGenerationException,
TestSuiteValidationException, InterruptedException {
FileProject project =
loadProjectFromPlugin(AF3ApplicationActivator.PLUGIN_ID, fileName, true);
Component testedComponent =
findContentElementByNameAndClass(project, componentName, Component.class);
ICommandStackService.getInstance().runAsCommand(project, () -> {
spec = createTestSuiteSpecification();
testedComponent.getSpecifications().add(spec);
RandomSpecificationPart rsp = createRandomSpecificationPart();
spec.getSpecifications().add(rsp);
rsp.setNumberOfTestCases(TEST_CASES_NUM);
for(InputPort port : testedComponent.getInputPorts()) {
rsp.getPortBinding().add(createPortBinding(port));
}
});
RandomTestSuiteGenerator rtsg = new RandomTestSuiteGenerator();
TestSuite testSuite = rtsg.generate(spec, new NullProgressMonitor());
testedComponent.getSpecifications().add(testSuite);
GenericGCCPlatformTestSuiteValidator validator = new GenericGCCPlatformTestSuiteValidator();
assertTrue(validator.canValidate(testSuite));
TestSuite newSuite = validator.validate(testSuite, new NullProgressMonitor());
List<Pair<FileProject, TestCase>> projectsAndTestCases =
new ArrayList<Pair<FileProject, TestCase>>();
for(TestCase tc : newSuite.getTestCases()) {
projectsAndTestCases.add(new Pair<FileProject, TestCase>(project, tc));
}
return projectsAndTestCases;
}
/** Simple test if code generation succeeded. */
@Test
public void codeGenerationTest() {
int caseNum = 0;
StringBuffer debugInfo = new StringBuffer();
// test the equivalence of expected value and simulated value of all TestSteps
for(int stepNum = 0; stepNum < testCase.getTestSteps().size(); stepNum++) {
TestStep step = testCase.getTestSteps().get(stepNum);
int inputPortPos = 0;
debugInfo.append("Step " + stepNum + " (");
// configure debug info StringBuffer with name and value of Inputports
for(TestInput ti : step.getInputs()) {
InputPort ip = testCase.getTestSuite().getInputPorts().get(inputPortPos);
debugInfo.append(ip.getName() + ":" + ti.getValue() + ", ");
inputPortPos++;
}
debugInfo.append(") -- ");
for(TestOutput to : step.getOutputs()) {
if(to.getExpectedValue() instanceof DoubleConst) {
// reduced equality assertion: expected and simulated are equal if first three
// characters are equal
String expected = to.getExpectedValue().toString().substring(0, 3);
String simulated = to.getSimulatedValue().toString().substring(0, 3);
if(!expected.equals(simulated)) {
assertEquals("Project: " + project.getName() +
" Output mismatch in test case " + caseNum + " (test step " +
stepNum + ") -- inputs are: " + debugInfo, expected, simulated);
}
} else {
if(!to.getExpectedValue().equals(to.getSimulatedValue())) {
// FIXME AssertionFailedError Bug #1164 {@link
// https://af3.fortiss.org/issues/1164}
assertEquals("Project: " + project.getName() +
" Output mismatch in test case " + caseNum + " (test step " +
stepNum + ") -- inputs are: " + debugInfo, to.getExpectedValue(),
to.getSimulatedValue());
}
}
}
}
caseNum++;
}
}
<!-- (c) 2017 fortiss GmbH -->
<body>
This package contains tests for assuring the alignment of the simulator and C code generator.
</body>
<!-- (c) 2017 fortiss GmbH -->
<body>
This package contains tests for assuring the alignment of the simulator and Java code generator.
</body>
Markdown is supported
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