tddwizard / magento2-fixtures

Fixture library for Magento 2 integration tests by @schmengler (@integer-net)
http://tddwizard.com/
MIT License
143 stars 28 forks source link

FixtureRollback vs @magentoDbIsolation #29

Open bartoszkubicki opened 5 years ago

bartoszkubicki commented 5 years ago

First of all many thank for this awesome library - today I was able to setup scenario for reordering single order item within 15 minutes, while using your library for the first time!

I have a question though, about FixtureRollback classes and mentioned annotation. Is it necessary to use rollback, if we mark test with db isolation? Isn't it all performed in db transaction?

schmengler commented 5 years ago

Thank you, good to hear!

It's true, if you run your test in db isolation, rollback is not necessary, and using db isolation is generally a safe practice.

Sometimes there are reasons not to, though. For example, if indexing happens during tests, it doesn't work because temporary tables cannot be created inside a transaction. In Magento 2.2 the transaction would be silently committed, in 2.3 there's an exception.

You can see how I handle this for product fixtures here: https://github.com/tddwizard/magento2-fixtures/commit/c67e0fd385f367eb5388b0550f26cc04e72c544f

I'll leave this issue open as request for documentation