Repository navigation
[PHPUnit60] Skip tests in classes with own asserting lifecycle methods in AddDoesNotPerformAssertionToNonAssertingTestRector - #831
Merged
Conversation
…s in AddDoesNotPerformAssertionToNonAssertingTestRector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of rectorphp/rector#9965, split from #827.
PHPUnit counts assertions made in lifecycle methods toward every test of the class. A test whose own body asserts nothing still "performs assertions" when
setUp(),tearDown(),assertPreConditions(),assertPostConditions(), a#[Before]/#[After]/#[PreCondition]/#[PostCondition]method or a@before/@after/@preCondition/@postConditionmethod asserts. WithfailOnRisky, the added#[DoesNotPerformAssertions]then fails the test.Change
New
LifecycleMethodAssertAnalyzer, which checks only the lifecycle methods of the test's own class:getFile()->getNewStmts()), so nothing is parsed again. NoAstResolverfor ancestors or traits here, that stays in [PHPUnit60] Skip tests in classes with asserting lifecycle methods in AddDoesNotPerformAssertionToNonAssertingTestRector #827.AssertCallAnalyzeras before (helpers,parent::setUp()).Class_node, so all test methods of a class share it.Bench
New
bench/does_not_perform_assertion_own_lifecycle_bench.php: 300 test classes with ownsetUp()andtearDown(), every other one asserting insetUp(). The existing lifecycle bench now sets the currentFileonCurrentFileProvider, likeAbstractRectorTestCasedoes, as the rule reads it. CPU, 3 runs, local:mainWithout the per-class cache the own-lifecycle bench was ~0.44 s.