numirias / pytest-json-report

🗒️ A pytest plugin to report test results as JSON
MIT License
147 stars 39 forks source link

Rerun tests get reported as failures #31

Closed jacebrowning closed 5 years ago

jacebrowning commented 5 years ago

I am using https://github.com/box/flaky to attempt to rerun flaky tests. Here is some code that emulates flakiness:

import pytest

FLAKY_RUNS = 0

@pytest.mark.flaky
def test_flaky_pass():
    assert 1 + 1 == 2

@pytest.mark.flaky
def test_flaky_fail():
    global FLAKY_RUNS
    FLAKY_RUNS += 1
    assert FLAKY_RUNS == 2

The pytest summary reports:

=== 2 passed in 0.87 seconds ===

The https://github.com/pytest-dev/pytest-html report shows:

But the JSON report from this library shows:

{
  "created": 1549296205.722281,
  "duration": 0.8702988624572754,
  "exitcode": 0,
  },
  "summary": {
    "passed": 1,
    "failed": 1,
    "total": 2
  },
  "collectors": [
    { ...

How can I get pytest-json-report to treat the successfully rerun test as a pass?

numirias commented 5 years ago

Thanks for reporting. I'm afraid I need more information since your test case runs as expected for me locally and on Travis (see #33)

jacebrowning commented 5 years ago

I should have confirmed that on was on the latest version. 😄

Upgrading from 0.7.0 to 1.0.2 fixes this!