Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

@setUp and @tearDown Annotations PHPUnit

I have a question for the /** @setUp */ and /** @tearDown */ annotations in PHPUnit and it only goes with documentation.

I found various annotations in PHPUnit here https://phpunit.de/manual/current/en/appendixes.annotations.html but I didn't see @setUp or @tearDown.

So my question is, is this a Laravel specific feature or is it new in PHPUnit?

like image 416
David Soto Avatar asked Nov 10 '22 12:11

David Soto


1 Answers

@setUp and @tearDown are phpUnit related.

setUp function will be run before each of your test, it's useful if you have to init the same object for every test in the class

tearDown is the opposite, it will be run after each test of the class

like image 56
Sylwit Avatar answered Nov 14 '22 23:11

Sylwit