Search in sources :

Example 1 with MockPrinter

use of com.intellij.execution.testframework.sm.runner.ui.MockPrinter in project intellij-community by JetBrains.

the class GeneralToSMTRunnerEventsConvertorTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    TestConsoleProperties consoleProperties = createConsoleProperties();
    TestConsoleProperties.HIDE_PASSED_TESTS.set(consoleProperties, false);
    TestConsoleProperties.OPEN_FAILURE_LINE.set(consoleProperties, false);
    TestConsoleProperties.SCROLL_TO_SOURCE.set(consoleProperties, false);
    TestConsoleProperties.SELECT_FIRST_DEFECT.set(consoleProperties, false);
    TestConsoleProperties.TRACK_RUNNING_TEST.set(consoleProperties, false);
    final ExecutionEnvironment environment = new ExecutionEnvironment();
    myMockResettablePrinter = new MockPrinter(true);
    myConsole = new MyConsoleView(consoleProperties, environment);
    myConsole.initUI();
    myResultsViewer = myConsole.getResultsViewer();
    myEventsProcessor = new GeneralToSMTRunnerEventsConvertor(consoleProperties.getProject(), myResultsViewer.getTestsRootNode(), "SMTestFramework");
    myEventsProcessor.addEventsListener(myResultsViewer);
    myTreeModel = myResultsViewer.getTreeView().getModel();
    myEventsProcessor.onStartTesting();
}
Also used : ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) MockPrinter(com.intellij.execution.testframework.sm.runner.ui.MockPrinter) TestConsoleProperties(com.intellij.execution.testframework.TestConsoleProperties)

Example 2 with MockPrinter

use of com.intellij.execution.testframework.sm.runner.ui.MockPrinter in project intellij-community by JetBrains.

the class SMTRunnerConsoleTest method testProcessor_OnFailure_EmptyStacktrace.

public void testProcessor_OnFailure_EmptyStacktrace() {
    final SMTestProxy myTest1 = startTestWithPrinter("my_test");
    myEventsProcessor.onTestFailure(new TestFailedEvent("my_test", "error msg", "\n\n", false, null, null));
    myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
    myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
    assertAllOutputs(myMockResettablePrinter, "stdout1 ", "\nerror msg\nstderr1 ", "");
    final MockPrinter mockPrinter1 = new MockPrinter(true);
    mockPrinter1.onNewAvailable(myTest1);
    assertAllOutputs(mockPrinter1, "stdout1 ", "stderr1 \nerror msg\n", "");
}
Also used : MockPrinter(com.intellij.execution.testframework.sm.runner.ui.MockPrinter)

Example 3 with MockPrinter

use of com.intellij.execution.testframework.sm.runner.ui.MockPrinter in project intellij-community by JetBrains.

the class SMTRunnerConsoleTest method testProcessor_OnError.

public void testProcessor_OnError() {
    final SMTestProxy myTest1 = startTestWithPrinter("my_test");
    myEventsProcessor.onTestFailure(new TestFailedEvent("my_test", "error msg", "method1:1\nmethod2:2", true, 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", true, 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", "");
}
Also used : MockPrinter(com.intellij.execution.testframework.sm.runner.ui.MockPrinter)

Example 4 with MockPrinter

use of com.intellij.execution.testframework.sm.runner.ui.MockPrinter in project intellij-community by JetBrains.

the class SMTRunnerConsoleTest method testProcessor_Suite_OnErrorMsg.

public void testProcessor_Suite_OnErrorMsg() {
    myEventsProcessor.onError("error msg:root", "method1:1\nmethod2:2", true);
    myEventsProcessor.onSuiteStarted(new TestSuiteStartedEvent("suite", null));
    final SMTestProxy suite = myEventsProcessor.getCurrentSuite();
    suite.setPrinter(myMockResettablePrinter);
    myEventsProcessor.onError("error msg:suite", "method1:1\nmethod2:2", true);
    assertAllOutputs(myMockResettablePrinter, "", "\n" + "error msg:suite\n" + "method1:1\n" + "method2:2\n", "");
    final MockPrinter mockSuitePrinter = new MockPrinter(true);
    mockSuitePrinter.onNewAvailable(suite);
    assertAllOutputs(mockSuitePrinter, "", "\n" + "error msg:suite\n" + "method1:1\n" + "method2:2\n", "");
    final MockPrinter mockRootSuitePrinter = new MockPrinter(true);
    mockRootSuitePrinter.onNewAvailable(myRootSuite);
    assertAllOutputs(mockRootSuitePrinter, "", "\n" + "error msg:root\n" + "method1:1\n" + "method2:2\n" + "\n" + "error msg:suite\n" + "method1:1\n" + "method2:2\n", "");
}
Also used : MockPrinter(com.intellij.execution.testframework.sm.runner.ui.MockPrinter)

Example 5 with MockPrinter

use of com.intellij.execution.testframework.sm.runner.ui.MockPrinter in project intellij-community by JetBrains.

the class SMTRunnerConsoleTest method testProcessor_OnIgnored_WithStacktrace.

public void testProcessor_OnIgnored_WithStacktrace() {
    final SMTestProxy myTest1 = startTestWithPrinter("my_test");
    myEventsProcessor.onTestIgnored(new TestIgnoredEvent("my_test", "ignored2 msg", "method1:1\nmethod2:2"));
    myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
    myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
    assertAllOutputs(myMockResettablePrinter, "stdout1 ", "\nmethod1:1\nmethod2:2\nstderr1 ", "\nignored2 msg\n");
    final MockPrinter mockPrinter1 = new MockPrinter(true);
    mockPrinter1.onNewAvailable(myTest1);
    assertAllOutputs(mockPrinter1, "stdout1 ", "stderr1 \nmethod1:1\nmethod2:2\n", "\nignored2 msg\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.onTestIgnored(new TestIgnoredEvent("my_test2", "ignored msg", "method1:1\nmethod2:2"));
    assertAllOutputs(myMockResettablePrinter, "stdout1 ", "stderr1 \nmethod1:1\nmethod2:2\n", "\nignored msg\n");
    final MockPrinter mockPrinter2 = new MockPrinter(true);
    mockPrinter2.onNewAvailable(myTest2);
    assertAllOutputs(mockPrinter2, "stdout1 ", "stderr1 \nmethod1:1\nmethod2:2\n", "\nignored msg\n");
}
Also used : MockPrinter(com.intellij.execution.testframework.sm.runner.ui.MockPrinter)

Aggregations

MockPrinter (com.intellij.execution.testframework.sm.runner.ui.MockPrinter)15 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)3 TestConsoleProperties (com.intellij.execution.testframework.TestConsoleProperties)3 DefaultRunExecutor (com.intellij.execution.executors.DefaultRunExecutor)1 HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 StringReader (java.io.StringReader)1 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1 SAXTransformerFactory (javax.xml.transform.sax.SAXTransformerFactory)1 TransformerHandler (javax.xml.transform.sax.TransformerHandler)1 StreamResult (javax.xml.transform.stream.StreamResult)1