Search in sources :

Example 11 with MockPrinter

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

the class SMTRunnerConsoleTest method testProcessor_OnFailure_Comparision_MultilineTexts.

public void testProcessor_OnFailure_Comparision_MultilineTexts() {
    final SMTestProxy myTest1 = startTestWithPrinter("my_test");
    myEventsProcessor.onTestFailure(new TestFailedEvent("my_test", "error msg", "method1:1\nmethod2:2", false, "this is:\nactual", "this is:\nexpected"));
    myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
    myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
    assertAllOutputs(myMockResettablePrinter, "stdout1 ", "\nerror msg \n" + "\n" + "method1:1\n" + "method2:2\n" + "stderr1 ", "");
    final MockPrinter mockPrinter1 = new MockPrinter(true);
    mockPrinter1.onNewAvailable(myTest1);
    assertAllOutputs(mockPrinter1, "stdout1 ", "stderr1 \n" + "error msg \n" + "\n" + "method1:1\n" + "method2:2\n", "");
}
Also used : MockPrinter(com.intellij.execution.testframework.sm.runner.ui.MockPrinter)

Example 12 with MockPrinter

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

the class SMTRunnerConsoleTest method testProcessor_OnFailure_Comparision_Strings.

public void testProcessor_OnFailure_Comparision_Strings() {
    final SMTestProxy myTest1 = startTestWithPrinter("my_test");
    myEventsProcessor.onTestFailure(new TestFailedEvent("my_test", "error msg", "method1:1\nmethod2:2", false, "actual", "expected"));
    myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stdout1 ", true));
    myEventsProcessor.onTestOutput(new TestOutputEvent("my_test", "stderr1 ", false));
    assertAllOutputs(myMockResettablePrinter, // std out
    "stdout1 ", // std err
    "\n" + "error msg\n" + "expected\n" + "actual\n" + " \n" + "\n" + "method1:1\n" + "method2:2\n" + "stderr1 ", // std sys
    "Expected :Actual   :");
    final MockPrinter mockPrinter1 = new MockPrinter(true);
    mockPrinter1.onNewAvailable(myTest1);
    assertAllOutputs(mockPrinter1, // std out
    "stdout1 ", // std err
    "stderr1 \nerror msg\n" + "expected\n" + "actual\n" + " \n" + "\n" + "method1:1\nmethod2:2\n", // std sys
    "Expected :Actual   :");
}
Also used : MockPrinter(com.intellij.execution.testframework.sm.runner.ui.MockPrinter)

Example 13 with MockPrinter

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

the class SMTRunnerConsoleTest method testProcessor_OnIgnored.

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

Example 14 with MockPrinter

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

the class SMTestProxyTest method testTestFailedTwice.

public void testTestFailedTwice() {
    mySimpleTest.setStarted();
    mySimpleTest.setTestFailed("msg 1", "stack trace 1", false);
    assertFalse(mySimpleTest.isInProgress());
    assertTrue(mySimpleTest.wasLaunched());
    assertTrue(mySimpleTest.isDefect());
    assertTrue(mySimpleTest.getMagnitudeInfo() == Magnitude.FAILED_INDEX);
    final MockPrinter printer = new MockPrinter(true);
    mySimpleTest.printOn(printer);
    assertEquals("", printer.getStdOut());
    assertEquals("\nmsg 1\nstack trace 1\n", printer.getStdErr());
    assertEquals("", printer.getStdSys());
    mySimpleTest.setTestFailed("msg 2", "stack trace 2", false);
    assertFalse(mySimpleTest.isInProgress());
    assertTrue(mySimpleTest.wasLaunched());
    assertTrue(mySimpleTest.isDefect());
    assertTrue(mySimpleTest.getMagnitudeInfo() == Magnitude.FAILED_INDEX);
    printer.resetIfNecessary();
    mySimpleTest.printOn(printer);
    assertEquals("", printer.getStdOut());
    assertEquals("\nmsg 1\nstack trace 1\n\nmsg 2\nstack trace 2\n", printer.getStdErr());
    assertEquals("", printer.getStdSys());
    mySimpleTest.setFinished();
    assertFalse(mySimpleTest.isInProgress());
    assertTrue(mySimpleTest.wasLaunched());
    assertTrue(mySimpleTest.isDefect());
    assertTrue(mySimpleTest.getMagnitudeInfo() == Magnitude.FAILED_INDEX);
}
Also used : MockPrinter(com.intellij.execution.testframework.sm.runner.ui.MockPrinter)

Example 15 with MockPrinter

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

the class SMTestProxyTest method testMultipleAssertions.

public void testMultipleAssertions() {
    mySimpleTest.setStarted();
    mySimpleTest.setTestComparisonFailed("a", "stacktrace", "actual1", "expected1");
    mySimpleTest.setTestComparisonFailed("b", "stacktrace", "actual2", "expected2");
    mySimpleTest.setTestFailed("c", "stacktrace", false);
    mySimpleTest.setFinished();
    final MockPrinter printer = new MockPrinter(true) {

        @Override
        public void printHyperlink(String text, HyperlinkInfo info) {
            print(text, ConsoleViewContentType.SYSTEM_OUTPUT);
        }
    };
    mySimpleTest.printOn(printer);
    assertEquals("", printer.getStdOut());
    assertEquals("\n" + "a\n" + "Expected :expected1\n" + "Actual   :actual1\n" + " <Click to see difference>\n" + "\n" + "stacktrace\n" + "\n" + "b\n" + "Expected :expected2\n" + "Actual   :actual2\n" + " <Click to see difference>\n" + "\n" + "stacktrace\n" + "\n" + "c\n" + "stacktrace\n", printer.getAllOut());
}
Also used : MockPrinter(com.intellij.execution.testframework.sm.runner.ui.MockPrinter) HyperlinkInfo(com.intellij.execution.filters.HyperlinkInfo)

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