m_tester[0].addListener(vl);
}
// We always want to see the tests drawn
m_tester[0].addListener(new VisualisationListener());
// Redirect model's output to string
Model md = m_tester[0].getModel();
Writer defWriter = md.getOutput();
md.setOutput(sw);
// This writer updates the test results panel.
// TODO: move this class into PanelResultViewer.
Writer newWriter = new Writer() {
@Override
public void close() throws IOException {
}
@Override
public void flush() throws IOException {
}
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
StringBuffer str = new StringBuffer();
for (int i = off; i < off + len; i++) {
str.append(cbuf[i]);
}
gui.getResultViewer().updateRunTimeInformation(str.toString());
}
};
md.setOutput(newWriter);
for (int i = 0; i < COVERAGE_NUM; i++) {
if (bCoverage[i])
coverage[i].clear();
}
if (m_tester[0] instanceof QuickTester) {
QuickTester tester = (QuickTester) m_tester[0];
tester.clear();
}
// Generate tests
//System.err.println("Generating " + project.getWalkLength() + " tests with " + m_tester[0]);
m_tester[0].generate(project.getWalkLength());
// Print out generated model coverage metrics
for (int metric = 0; metric < COVERAGE_NUM; metric++) {
if (bCoverage[metric]) {
try {
newWriter.write(TestExeModel.COVERAGE_MATRIX[metric] + " = " + coverage[metric].toString() + "\n");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
// Reset model's output to default value
md.setOutput(defWriter);
// Recover System.out
output = baos.toString();
System.out.println(output);
// Restore system.out to default value.