Fixtures

The next important concept is that of fixtures. Fixtures are pieces of code which run before and/or after every test method. Fixtures serve two main purposes:

  1. Set-up fixtures ensure that the test environment is in an expected state before a test is run.
  2. Tear-down fixtures clean up the environment after a test has been run, generally by freeing up resources.

For example, a set-up fixture might create a specific entry in a database prior to running a test. Similarly, a tear-down fixture might remove database entries created by a test. Fixtures are not required for tests, but they are very common, and they are often critical for making tests repeatable.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset