2

I am following the latest official manual for EcomDev_PHPUnit with the latest version of that module and Magento CE.

I understand that a fixture is a set of data in a YAML format that is used to perform tests. However, how do I get the unit test to use the live database and not a fixture?

Thanks in advance for any help/tips/pointers.

6

Be warned, probably not the answer you want:

you don't run tests on production db contents.

Unit (and integration) testing should not be done against a live database, but against a fixed state of data.

The purpose os tests is to ensure code runs right.
Change the code, and if the tests still run, you are okay.

Change the data though, and you will never know when a test doesn't run successfully any more, if the reason is a code change or a data change.

Because of that reason you always want to use data fixtures for tests.

Maybe you are looking for a way to do acceptance tests, rather then code tests, that is, integration or unit tests. But even for acceptance you want to use fixtures.

The only reason I can come up with to run some kind of tests with a copy of live data would be to do server monitoring.
In that case, you would have to configure EcomDev_PHPUnit to use the same DB as Magento and then disable the security check in EcomDev_PHPUnit that ensures the test DB isn't the same as the live DB (that would be a hack and I'll won't write further on that as I think it would be a bad idea, as stated above).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.