use of com.intellij.execution.testframework.sm.runner.ui.MockPrinter in project intellij-community by JetBrains.
the class SMTRunnerConsoleTest method testProcessor_OnFailure.
public void testProcessor_OnFailure() {
final SMTestProxy myTest1 = startTestWithPrinter("my_test");
myEventsProcessor.onTestFailure(new TestFailedEvent("my_test", "error msg", "method1:1\nmethod2:2", false, null, null));
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
assertAllOutputs(myMockResettablePrinter, "stdout1 ", "\nerror msg\nmethod1:1\nmethod2:2\nstderr1 ", "");
final MockPrinter mockPrinter1 = new MockPrinter(true);
mockPrinter1.onNewAvailable(myTest1);
assertAllOutputs(mockPrinter1, "stdout1 ", "stderr1 \nerror msg\nmethod1:1\nmethod2:2\n", "");
//other output order
final SMTestProxy myTest2 = startTestWithPrinter("my_test2");
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test2", "stdout1 ", true));
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test2", "stderr1 ", false));
myEventsProcessor.onTestFailure(new TestFailedEvent("my_test2", "error msg", "method1:1\nmethod2:2", false, null, null));
assertAllOutputs(myMockResettablePrinter, "stdout1 ", "stderr1 \nerror msg\nmethod1:1\nmethod2:2\n", "");
final MockPrinter mockPrinter2 = new MockPrinter(true);
mockPrinter2.onNewAvailable(myTest2);
assertAllOutputs(mockPrinter2, "stdout1 ", "stderr1 \nerror msg\nmethod1:1\nmethod2:2\n", "");
}
use of com.intellij.execution.testframework.sm.runner.ui.MockPrinter in project intellij-community by JetBrains.
the class SMTRunnerConsoleTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
final TestConsoleProperties consoleProperties = createConsoleProperties();
final ExecutionEnvironment environment = new ExecutionEnvironment();
myMockResettablePrinter = new MockPrinter(true);
myConsole = new MyConsoleView(consoleProperties, environment);
myConsole.initUI();
myResultsViewer = myConsole.getResultsViewer();
myRootSuite = myResultsViewer.getTestsRootNode();
myEventsProcessor = new GeneralToSMTRunnerEventsConvertor(consoleProperties.getProject(), myResultsViewer.getTestsRootNode(), "SMTestFramework");
myEventsProcessor.onStartTesting();
}
use of com.intellij.execution.testframework.sm.runner.ui.MockPrinter in project intellij-community by JetBrains.
the class SMTRunnerConsoleTest method testProcessor_OnErrorMsg.
public void testProcessor_OnErrorMsg() {
final SMTestProxy myTest1 = startTestWithPrinter("my_test");
myEventsProcessor.onError("error msg", "method1:1\nmethod2:2", true);
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
assertAllOutputs(myMockResettablePrinter, "stdout1 ", "\nerror msg\nmethod1:1\nmethod2:2\nstderr1 ", "");
final MockPrinter mockPrinter1 = new MockPrinter(true);
mockPrinter1.onNewAvailable(myTest1);
assertAllOutputs(mockPrinter1, "stdout1 ", "\n" + "error msg\n" + "method1:1\n" + "method2:2\n" + "stderr1 ", "");
myEventsProcessor.onTestFinished(new TestFinishedEvent("my_test", 1l));
myTest1.setFinished();
//other output order
final SMTestProxy myTest2 = startTestWithPrinter("my_test2");
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test2", "stdout1 ", true));
myEventsProcessor.onTestOutput(new TestOutputEvent("my_test2", "stderr1 ", false));
myEventsProcessor.onError("error msg", "method1:1\nmethod2:2", true);
assertAllOutputs(myMockResettablePrinter, "stdout1 ", "stderr1 \nerror msg\nmethod1:1\nmethod2:2\n", "");
final MockPrinter mockPrinter2 = new MockPrinter(true);
mockPrinter2.onNewAvailable(myTest2);
assertAllOutputs(mockPrinter2, "stdout1 ", "stderr1 \nerror msg\nmethod1:1\nmethod2:2\n", "");
}
use of com.intellij.execution.testframework.sm.runner.ui.MockPrinter in project intellij-plugins by JetBrains.
the class DartTestEventsConverterTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
myNodes = new HashMap<>();
final ExecutionEnvironment environment = new ExecutionEnvironment();
myMockResettablePrinter = new MockPrinter(true);
TestConsoleProperties consoleProperties = createConsoleProperties();
myConsole = new MyConsoleView(consoleProperties, environment);
myConsole.initUI();
myResultsViewer = myConsole.getResultsViewer();
myEventsConverter = new DartTestEventsConverter(DartTestRunningState.DART_FRAMEWORK_NAME, consoleProperties, DartUrlResolver.getInstance(getProject(), getSourceRoot()));
myEventsProcessor = new DartTestEventsProcessor(consoleProperties.getProject(), DartTestRunningState.DART_FRAMEWORK_NAME);
myEventsProcessor.addEventsListener(myResultsViewer);
myEventsConverter.setProcessor(myEventsProcessor);
myTreeModel = myResultsViewer.getTreeView() == null ? null : (DefaultTreeModel) myResultsViewer.getTreeView().getModel();
assertNotNull(myTreeModel);
myParentNode = (DefaultMutableTreeNode) myTreeModel.getRoot();
myEventsProcessor.onStartTesting();
}
use of com.intellij.execution.testframework.sm.runner.ui.MockPrinter in project intellij-community by JetBrains.
the class GeneralToSMTRunnerEventsConvertorTest method testPreserveFullOutputAfterImport.
public void testPreserveFullOutputAfterImport() throws Exception {
mySuite.addChild(mySimpleTest);
for (int i = 0; i < 550; i++) {
String message = "line" + i + "\n";
mySimpleTest.addLast(printer -> printer.print(message, ConsoleViewContentType.NORMAL_OUTPUT));
}
mySimpleTest.setFinished();
mySuite.setFinished();
SAXTransformerFactory transformerFactory = (SAXTransformerFactory) TransformerFactory.newInstance();
TransformerHandler handler = transformerFactory.newTransformerHandler();
handler.getTransformer().setOutputProperty(OutputKeys.INDENT, "yes");
handler.getTransformer().setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
File output = FileUtil.createTempFile("output", "");
try {
FileUtilRt.createParentDirs(output);
handler.setResult(new StreamResult(new FileWriter(output)));
MockRuntimeConfiguration configuration = new MockRuntimeConfiguration(getProject());
TestResultsXmlFormatter.execute(mySuite, configuration, new SMTRunnerConsoleProperties(configuration, "framework", new DefaultRunExecutor()), handler);
String savedText = FileUtil.loadFile(output);
assertTrue(savedText.split("\n").length > 550);
myEventsProcessor.onStartTesting();
ImportedToGeneralTestEventsConverter.parseTestResults(() -> new StringReader(savedText), myEventsProcessor);
myEventsProcessor.onFinishTesting();
List<? extends SMTestProxy> children = myResultsViewer.getTestsRootNode().getChildren();
assertSize(1, children);
SMTestProxy testProxy = children.get(0);
MockPrinter mockPrinter = new MockPrinter();
testProxy.printOn(mockPrinter);
assertSize(550, mockPrinter.getAllOut().split("\n"));
} finally {
FileUtil.delete(output);
}
}
Aggregations