Respect / Respect/Validation

Remove RuleTestCase in favor of TestCase

Open
#1,667 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

CI/Testing
Dominant language
PHP
Stars
6k
Forks
773
Avg merge
10h 6m
Merged PRs (30d)
17

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating Respect\Validation\Test\RuleTestCase, its subclasses, and the existing Respect\Validation\Test\TestCase usage. Migrate validator tests so each test is built independently with TestCase, then run the PHPUnit suite and coverage checks; done means RuleTestCase is no longer needed and the tests retain their coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
testing
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.