void () { runPythonTest(new PyProcessWithConsoleTestTask<PyTestTestProcessRunner>("/testRunner/env/pytest", SdkCreationType.EMPTY_SDK) { @NotNull @Override protected PyTestTestProcessRunner createProcessRunner() { return new PyTestTestProcessRunner("test2.py", 1); } @Override protected void checkTestResults(@NotNull final PyTestTestProcessRunner runner, @NotNull final String stdout, @NotNull final String stderr, @NotNull final String all, int exitCode) { if (runner.getCurrentRerunStep() > 0) { assertEquals(runner.getFormattedTestTree(), 4, runner.getAllTestsCount()); assertEquals(runner.getFormattedTestTree(), 0, runner.getPassedTestsCount()); assertEquals(runner.getFormattedTestTree(), 4, runner.getFailedTestsCount()); return; } assertEquals(runner.getFormattedTestTree(), 9, runner.getAllTestsCount()); assertEquals(runner.getFormattedTestTree(), 5, runner.getPassedTestsCount()); assertEquals(runner.getFormattedTestTree(), 4, runner.getFailedTestsCount()); // Py.test may report F before failed test, so we check string contains, not starts with assertThat("No test stdout", fillPrinter(runner.findTestByName("testOne")).getStdOut(), containsString("I am test1")); // Ensure test has stdout even it fails final AbstractTestProxy testFail = runner.findTestByName("testFail"); assertThat("No stdout for fail", fillPrinter(testFail).getStdOut(), containsString("I will fail")); // This test has "sleep(1)", so duration should be >=1000 assertThat("Wrong duration", testFail.getDuration(), Matchers.greaterThanOrEqualTo(900L)); } }); }