diff --git a/src/pytest_xflaky/plugin.py b/src/pytest_xflaky/plugin.py index d56a315..dd2c26a 100644 --- a/src/pytest_xflaky/plugin.py +++ b/src/pytest_xflaky/plugin.py @@ -70,12 +70,14 @@ def generate_report(self): min_failures=self.config.option.xflaky_min_failures, ) - flaky_tests = finder.run() + flaky_tests, total_tests = finder.run() if flaky_tests: self.print_report(flaky_tests) - pytest.exit(1) + pytest.exit( + f"Flaky tests found: {flaky_tests}/{total_tests}", return_code=1 + ) - print("No flaky tests found") + pytest.exit("No flaky tests found", return_code=0) def print_report(self, flaky_tests): for flaky_test in flaky_tests: @@ -96,7 +98,9 @@ def __init__(self, *, directory: str, min_failures: int): def run(self) -> list[FlakyTest]: ok = {} failures = {} + total = 0 for test, failure in self.collect_tests(): + total += 1 if failure: failures.setdefault(test, 0) failures[test] += 1 @@ -113,7 +117,7 @@ def run(self) -> list[FlakyTest]: FlakyTest(test=test, ok=ok_, failed=failures[test]) ) - return flaky_tests + return flaky_tests, total def collect_tests(self): for f in os.listdir(self.directory):