Tim Rogers
Tim Rogers

Reputation: 496

Test skipped because of an error in hook method in PHPUnit

When running PHPUnit, some tests are skipped with the message 'Test skipped because of an error in hook method'. What is causing this and how do I prevent the tests from being skipped?

Upvotes: 3

Views: 723

Answers (1)

Tim Rogers
Tim Rogers

Reputation: 496

Tests in PHPUnit can have certain magic methods called hooks. These are called by PHPUnit automatically. The methods are:

  • setUp()
  • tearDown()
  • setUpBeforeClass()
  • tearDownAfterClass()
  • onNotSuccessfulTest()

An error in any of these methods will cause the test to be skipped with the error 'Test skipped because of an error in hook method'. To prevent the test being skipped, check each of these methods to find the error and fix it.

Upvotes: 4

Related Questions