Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPUnit passing a test with no assertions within config

Tags:

phpunit

I want to pass tests which get the following: "This test did not perform any assertions"

I know I could add something like assertTrue(true) however is it possible to add something to the config to make these tests pass cleaner?

I'm pretty sure this only happens since version PHPUnit 3.5.0 with the introduction of --strict

like image 816
Oliver Bayes-Shelton Avatar asked Jul 12 '11 14:07

Oliver Bayes-Shelton


People also ask

What is assertion in PHPUnit?

The assertEquals() function is a builtin function in PHPUnit and is used to assert whether the actual obtained value is equals to expected value or not. This assertion will return true in the case if the expected value is the same as the actual value else returns false.

What is PHPUnit testing?

PHPUnit is a unit testing framework for the PHP programming language. It is an instance of the xUnit design for unit testing systems that began with SUnit and became popular with JUnit. Even a small software development project usually takes hours of hard work.

What is mock PHPUnit?

Likewise, PHPUnit mock object is a simulated object that performs the behavior of a part of the application that is required in the unit test. The developers control the mock object by defining the pre-computed results on the actions.


1 Answers

Use the @doesNotPerformAssertions annotation:

/**
 * @doesNotPerformAssertions
 */
public function testCodeWithoutUsingAssertions()
{
    // do stuff...
}
like image 87
Nathan Arthur Avatar answered Oct 13 '22 11:10

Nathan Arthur