Skip to content

Commit

Permalink
test: improve testing
Browse files Browse the repository at this point in the history
  • Loading branch information
aaltat authored and Tatu Aalto committed Jul 6, 2022
1 parent be26b74 commit 837473c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/resources/xunit_01.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testsuite name="pytest" errors="0" failures="0" skipped="0" tests="2" time="1.188" timestamp="2022-05-30T14:49:18.865623" hostname="PC">
<testcase classname="tests.test_me" name="test_01" file="tests\test_me.py" line="0" time="0.025"/>
<testcase classname="tests.test_me" name="test_02" file="tests\test_me.py" line="0" time="0.014"/>
</testsuite>
</testsuites>
7 changes: 7 additions & 0 deletions tests/resources/xunit_02.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testsuite name="pytest" errors="0" failures="0" skipped="0" tests="2" time="1.188" timestamp="2022-05-30T15:49:18.865623" hostname="PC">
<testcase classname="tests.test_me" name="test_01" file="tests\test_me.py" line="0" time="0.025"/>
<testcase classname="tests.test_me" name="test_02" file="tests\test_me.py" line="0" time="0.014"/>
</testsuite>
</testsuites>
21 changes: 21 additions & 0 deletions tests/test_check_flakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,3 +601,24 @@ def test_no_flips(tmpdir: LocalPath):
assert process.returncode == 0, f"stdout:\n{process.stdout.decode(encoding='utf-16')}"
data = process.stderr.decode().strip()
assert data == f"No flaky tests."


def test_no_flips_xml(tmpdir: LocalPath, capsys):
test_path = Path(__file__).parent
xunit_files = test_path / "resources"
script_path = test_path / ".." / "flaky_tests_detection" / "check_flakes.py"
script_path = script_path.resolve()

args = [
str(sys.executable),
str(script_path),
f"--junit-files={xunit_files}",
"--grouping-option=runs",
"--window-size=2",
"--window-count=3",
"--top-n=1",
]
process = subprocess.run(args, cwd=tmpdir, capture_output=True)
assert process.returncode == 0, f"stdout:\n{process.stdout.decode(encoding='utf-16')}"
data = process.stderr.decode().strip()
assert data == f"No flaky tests."

0 comments on commit 837473c

Please sign in to comment.