mirror of
https://github.com/hneemann/Digital.git
synced 2025-10-03 01:41:16 -04:00
More concise handling of errors occurring during test execution.
This commit is contained in:
parent
70fe4f8d77
commit
e1c65d1f98
@ -9,6 +9,7 @@ import de.neemann.digital.draw.library.ElementNotFoundException;
|
|||||||
import de.neemann.digital.draw.model.ModelCreator;
|
import de.neemann.digital.draw.model.ModelCreator;
|
||||||
import de.neemann.digital.lang.Lang;
|
import de.neemann.digital.lang.Lang;
|
||||||
import de.neemann.digital.testing.*;
|
import de.neemann.digital.testing.*;
|
||||||
|
import de.neemann.gui.ErrorMessage;
|
||||||
import de.neemann.gui.IconCreator;
|
import de.neemann.gui.IconCreator;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@ -54,6 +55,9 @@ public class TestResultDialog extends JDialog {
|
|||||||
|
|
||||||
TestResult tr = new TestResult(ts.data).create(model);
|
TestResult tr = new TestResult(ts.data).create(model);
|
||||||
|
|
||||||
|
if (tr.getException() != null)
|
||||||
|
SwingUtilities.invokeLater(new ErrorMessage(Lang.get("msg_errorWhileExecutingTests_N0", ts.name)).addCause(tr.getException()).setComponent(this));
|
||||||
|
|
||||||
JTable table = new JTable(new TestResultModel(tr));
|
JTable table = new JTable(new TestResultModel(tr));
|
||||||
table.setDefaultRenderer(MatchedValue.class, new MatchedValueRenderer());
|
table.setDefaultRenderer(MatchedValue.class, new MatchedValueRenderer());
|
||||||
table.setDefaultRenderer(Integer.class, new NumberRenderer());
|
table.setDefaultRenderer(Integer.class, new NumberRenderer());
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package de.neemann.digital.gui.components.testing;
|
package de.neemann.digital.gui.components.testing;
|
||||||
|
|
||||||
|
import de.neemann.digital.lang.Lang;
|
||||||
import de.neemann.digital.testing.MatchedValue;
|
import de.neemann.digital.testing.MatchedValue;
|
||||||
import de.neemann.digital.testing.TestResult;
|
import de.neemann.digital.testing.TestResult;
|
||||||
|
|
||||||
@ -37,7 +38,7 @@ public class TestResultModel implements TableModel {
|
|||||||
@Override
|
@Override
|
||||||
public String getColumnName(int columnIndex) {
|
public String getColumnName(int columnIndex) {
|
||||||
if (columnIndex == 0)
|
if (columnIndex == 0)
|
||||||
return "No";
|
return Lang.get("number");
|
||||||
else
|
else
|
||||||
return testResult.getSignalName(columnIndex - 1);
|
return testResult.getSignalName(columnIndex - 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ public class TestResult {
|
|||||||
private final ArrayList<Value[]> lines;
|
private final ArrayList<Value[]> lines;
|
||||||
private final ArrayList<Value[]> results;
|
private final ArrayList<Value[]> results;
|
||||||
private boolean allPassed;
|
private boolean allPassed;
|
||||||
|
private Exception exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new testing result
|
* Creates a new testing result
|
||||||
@ -107,7 +108,13 @@ public class TestResult {
|
|||||||
in.value.setBool(!in.value.getBool());
|
in.value.setBool(!in.value.getBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
model.doStep();
|
model.doStep();
|
||||||
|
} catch (NodeException | RuntimeException e) {
|
||||||
|
exception = e;
|
||||||
|
allPassed = false;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
for (TestSignal out : outputs) {
|
for (TestSignal out : outputs) {
|
||||||
MatchedValue matchedValue = new MatchedValue(row[out.index], out.value);
|
MatchedValue matchedValue = new MatchedValue(row[out.index], out.value);
|
||||||
@ -287,4 +294,11 @@ public class TestResult {
|
|||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the exception thrown during test test execution, or null if there was no error.
|
||||||
|
*/
|
||||||
|
public Exception getException() {
|
||||||
|
return exception;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,7 @@ public class TestExamples extends TestCase {
|
|||||||
public void testTestExamples() throws Exception {
|
public void testTestExamples() throws Exception {
|
||||||
File examples = new File(Resources.getRoot(), "/dig/test");
|
File examples = new File(Resources.getRoot(), "/dig/test");
|
||||||
assertEquals(42, new FileScanner(this::check).scan(examples));
|
assertEquals(42, new FileScanner(this::check).scan(examples));
|
||||||
assertEquals(33, testCasesInFiles);
|
assertEquals(35, testCasesInFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user