TestCase
should not extend Assert
#5433
Labels
feature/assertion
Issues related to assertions and expectations
type/enhancement
A new idea that should be implemented
TestCase
is currently 2276 lines long and contains 129 functions, we can argue that this class concentrates too much responsibilities and is a god class. Unfortunately this class extendsAssert
which is 2293 lines long and contains 175 functions.Assert
) and inherit from too much logic/functionsAssert::assertTrue(...)
) to use composition. Unfortunately to enforce this convention you need to rely on external tools.self::assertXxx()
. This bloat classes even more, I saw it many times in the wild. If Assert was not available by default it would help to promote usage of composition over inheritance and create its own "Assert".My question is: could we remove the
Assert
inheritance fromTestCase
? What is the advantage of extendingAssert
? Writingself::
instead ofAssert::
doesn't seem to be a good reason.Proposal
AssertTrait
Assert
inTestCase
but "use"AssertTrait
to not have any BC in the next majorAssert::
Because there is a trait, it would be easy to have our own
Assert
by usinguse AssertTrait
and add methods.In a future version we could imagine to remove the trait from
TestCase
. By doing so, devs would be free to eitheruse AssertTrait
to keep the "legacy" syntax or to use composition (Assert::
).or
The text was updated successfully, but these errors were encountered: