...

/

Using Fixtures with pifpaf

Using Fixtures with pifpaf

Learn how to use fixtures with pifpaf.

While it is possible to run pifpaf globally around a test suite, it is also possible to use it inside tests and orchestrate some of its behavior.

pifpaf exports its drivers as test fixtures. In unit testing, fixtures represent components that are set up before a test and cleaned up after the test is finished. It is usually a good idea to build a specific kind of component for them, as they are reused in a lot of different places. In this case, pifpaf exports objects that represent the daemon launched. The object is initialized before each test and reset to its default values when the test is completed.

Testing using pifpaf and fixtures

In the following example, the test sets up a memcached instance before running each test. While this is slower and more expensive than using a memcached ...

Access this course and 1400+ top-rated courses and projects.