Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: review all tests to stabilize them more #497

Open
7 of 16 tasks
jrfnl opened this issue Jun 18, 2021 · 1 comment
Open
7 of 16 tasks

Test: review all tests to stabilize them more #497

jrfnl opened this issue Jun 18, 2021 · 1 comment

Comments

@jrfnl
Copy link
Member

jrfnl commented Jun 18, 2021

Currently, there are a lot of tests which follow a pattern along the lines of:

// Do something
$this->assertSame($expected, $result['key']['subkey']->property);

Tests like these are unstable as they may error out on any of the following:

  • $result not being an array.
  • The 'key' index not existing in $result
  • The 'subkey' index not existing in $result['key']
  • $result['key']['subkey'] not being an object
  • $result['key']['subkey'] not being an object of the expected type (instance of)
  • The object in $result['key']['subkey'] not having a property named $property.

Those tests should be stabilized and improved by changing them to something along the lines of:

// Do something
$this->assertIsArray($result);
$this->assertHaskey('key', $result);
$this->assertIsArray($result['key']);
$this->assertHaskey('subkey', $result['key']);
$this->assertIsObject($result['key']['subkey']);
$this->assertInstanceOf($classname, $result['key']['subkey']);
$this->assertHasAttribute('property', $result['key']['subkey']);
$this->assertSame($expected, $result['key']['subkey']->property);

Additionally, all tests which have multiple assertions, should pass the $message parameter to each assertion to help figure out which assertion has failed when a test fails.

Other review tasks (optional, but highly recommended)

  • Refactoring tests methods which do the same thing to data providers.
  • Enhancing existing data providers to use named data sets and keyed data entries.
  • Adding appropriate @covers tags.
  • Reviewing code coverage and adding additional tests to raise (both path as well as branch) code coverage.
  • Adding test documentation.
  • Potentially splitting test classes which do too much into multiple classes based on what is being covered by the tests.

Actions list

@jrfnl jrfnl added this to the 2.0.0 milestone Jun 18, 2021
@jrfnl jrfnl changed the title Test: review all tests to stabalize them more Test: review all tests to stabilize them more Jun 18, 2021
@jrfnl
Copy link
Member Author

jrfnl commented Aug 31, 2021

I've updated the issue description to contain a list of additional tasks and an action list so we can keep track of the status of this mini-project.

We'd welcome more people to get involved in this review. If you want to take any of these classes on, just leave a comment to "claim" it and I'll update the above list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant