DEV Community

Discussion on: Using Fixtures In Testing Symfony Application

Collapse
 
nicohaase profile image
Nico Haase

Keep in mind that loading fixtures within the test is a huge performance bottleneck. If all tests share the same set of fixtures, its way easier to load them before the first test and use something like dama/doctrine-test-bundle that starts a transaction before each test and rolls it back afterwards

Collapse
 
ahmedbhs profile image
Ahmed EBEN HASSINE 脳の流れ

Hello,

Could you please explain your comments about fixtures and test performance in more detail?

You mentioned that "loading fixtures within the test is a huge performance bottleneck." I'd like to understand:

  1. Why does liip/test-fixtures-bundle cause performance issues? Is it because fixtures are reloaded for each individual test case?

  2. With dama/doctrine-test-bundle, how does it work exactly? If I understand correctly, this package allows us to:

    • Load fixtures only once at the beginning
    • Then use transactions to isolate each test

But concretely, how is fixture loading organized with dama? Are fixtures loaded only once for the entire test suite, and then each test works on the same base data thanks to the transaction rollback system?

  1. **what's the probelem of using fixtures in my tests ? And what's the recommanded way to use fake data inside my tests ?

Thanks for these clarifications!

Best regards