Skip to content

Remove RuleTestCase in favor of TestCase #1667

@henriquemoody

Description

@henriquemoody

The Respect\Validation\Test\RuleTestCase provides an easy way of writing tests for validators, however that easiness comes with some drawbacks.

Problems

Data providers's code are no considered as covered

Data Provides are static, and are executed all at once before the test cases, while the coverage starts when the tests is run. That means that, even though we're testing different configurations for the constructor, they're not shown as covered when we enable coverage when we run PHPUnit.

Not IDE-friendly

IDEs usually allow you to trigger a run/debug on your test case, but because in this scenario, the test case is in a parent class, you can't simply trigger that test for a specific validator.

Apart from that, I don't know if that's the case for every IDE, but in PHPStorm, which is one of the best IDEs for PHP, you cannot trigger a run/debug for only a element in the data provider if the test case is not in the same file.

Solution

Use Respect\Validation\Test\TestCase, but build each test independently.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions