use of de.neemann.digital.testing.TestExecutor in project Digital by hneemann.
the class TestExamples method check.
/**
* Loads the model and initializes and test it if test cases are present
*
* @param dig the model file
*/
public static void check(File dig) throws Exception {
boolean shouldFail = dig.getName().endsWith("Error.dig");
ToBreakRunner br;
try {
br = new ToBreakRunner(dig);
} catch (Exception e) {
if (shouldFail) {
return;
} else
throw e;
}
try {
boolean isLib = dig.getPath().replace('\\', '/').contains("/lib/");
assertTrue("wrong locked mode", isLib == br.getCircuit().getAttributes().get(Keys.LOCKED_MODE));
try {
for (VisualElement el : br.getCircuit().getElements()) if (el.equalsDescription(TestCaseElement.TESTCASEDESCRIPTION)) {
String label = el.getElementAttributes().getCleanLabel();
TestCaseDescription td = el.getElementAttributes().get(TestCaseElement.TESTDATA);
Model model = new ModelCreator(br.getCircuit(), br.getLibrary()).createModel(false);
try {
TestExecutor tr = new TestExecutor(td).create(model);
if (label.contains("Failing"))
assertFalse(dig.getName() + ":" + label, tr.allPassed());
else
assertTrue(dig.getName() + ":" + label, tr.allPassed());
testCasesInFiles++;
} finally {
model.close();
}
}
} catch (Exception e) {
if (shouldFail) {
return;
} else
throw e;
}
assertFalse("File should fail but doesn't!", shouldFail);
} finally {
br.close();
}
}
use of de.neemann.digital.testing.TestExecutor in project Digital by hneemann.
the class JarComponentManagerTest method testJarAvailable.
public void testJarAvailable() throws PinException, NodeException, IOException, ElementNotFoundException, TestingDataException {
ToBreakRunner br = new ToBreakRunner("dig/jarLib/jarLibTest.dig") {
@Override
public void initLibrary(ElementLibrary library) {
library.addExternalJarComponents(new File(Resources.getRoot(), "dig/jarLib/pluginExample-1.0-SNAPSHOT.jar"));
assertNull(library.checkForException());
}
};
for (VisualElement ve : br.getCircuit().getElements()) {
if (ve.equalsDescription(TestCaseElement.TESTCASEDESCRIPTION)) {
TestCaseDescription td = ve.getElementAttributes().get(TestCaseElement.TESTDATA);
TestExecutor tr = new TestExecutor(td).create(br.getModel());
assertTrue(tr.allPassed());
}
}
}
Aggregations