Pin and document what configfailurepolicy actually does - #3426
Conversation
`FailurePolicyTest` covers @BeforeClass and @BeforeMethod, but neither @BeforeSuite nor @BeforeTest, under either policy. That is the gap GITHUB-2731 reports through: with `continue`, a failed @BeforeTest is the one and only case where the test method still runs. Record the whole 4x2 matrix so the inconsistency is visible in the test suite rather than only in an issue, and so that whichever way it is eventually settled, the expectations that have to move are named. The samples are top-level classes rather than nested ones on purpose: Gradle's TestNG runner collects the nested classes of a filtered class, and a @BeforeSuite that fails would then poison the whole run. Refs testng-team#2731
`XmlSuite.FailurePolicy` and its accessors carried no semantics at all
("Sets the configuration failure policy."), and the website documents
`continue` as "continue to execute the remaining tests in the suite" --
which only @BeforeTest actually does.
Write down the matrix the preceding commit pins, rather than either of
the two half-truths: `continue` narrows a config failure to the failing
instance for @BeforeClass and to the failing invocation for
@BeforeMethod, a failed @BeforeTest invalidates no instance at all so
those test methods run, and a @BeforeSuite failure stops the suite under
either policy. The failure is reported in every case, so `continue`
never turns a broken setup into a green run.
Refs testng-team#2731
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe change expands configuration failure policy documentation and adds characterization tests for ChangesConfiguration failure policy
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This PR documents existing configuration-failure behavior and adds characterization coverage without changing runtime behavior; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 7.69% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 8 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
configfailurepolicyis documented three different ways, and the three do not agree.testng-1.0.dtd) andTestNG.setConfigFailurePolicysay it decides whether a configuration method is attempted again after it has failed once.continuemakes TestNG "continue to execute the remaining tests in the suite".XmlSuite.FailurePolicyand its accessors said nothing at all ("Sets the configuration failure policy.").Running it settles which is true — and the answer is "both, depending on the level":
skipcontinue@BeforeSuite@BeforeTest@BeforeClass@BeforeMethodThe configuration failure is reported in all eight cases, so
continuenever turns a broken setup into a green run.That
@BeforeTestrow is exactly what #2731 reports, and its title ("only works for BeforeTest") is literally accurate.@BeforeClassand@BeforeMethoddo honourcontinue, but only by narrowing which instance or which invocation the failure invalidates — with a single instance and a single invocation there is nothing left to narrow, so the test still skips. A failed@BeforeTestis recorded against no instance at all, so it invalidates nothing.This PR does not change any of that behaviour. It makes it visible and writes it down:
test(config)—FailurePolicyTestcovers@BeforeClassand@BeforeMethodbut neither@BeforeSuitenor@BeforeTest, under either policy. That is the gap configfailurepolicy=continue only works for BeforeTest when using TestNG XML file #2731 went through. The new characterization test records the whole 4×2 matrix, so that whichever way the inconsistency is settled, the expectations that have to move are named.docs(config)— giveXmlSuite.FailurePolicy, both accessors,TestNG.setConfigFailurePolicyand the CLI option a description that matches the matrix instead of either half-truth. The DTD text was already right and is untouched.A companion PR against
testng-team.github.iofixes the website row that promises the behaviour TestNG does not have.What is deliberately left open
Whether
@BeforeTest+continueis the bug (too permissive, should align with@BeforeClass) or the model (and the other levels are too strict) is a design call, not a documentation one — it is the question @krmahadevan raised on #2731 in 2022 and it is still unanswered. Either answer breaks somebody. #2731 should stay open until it is decided; this PR just makes deciding it cheap.Did you remember to?
CHANGES.txt— no behaviour change, nothing user-visible to announce./gradlew autostyleApplySummary by CodeRabbit
Documentation
configFailurePolicybehavior forSKIPandCONTINUE.Tests