Is it bad practice to run tests on a database instead of on fake repositories?

前端 未结 11 1337
傲寒
傲寒 2020-12-10 04:01

I know what the advantages are and I use fake data when I am working with more complex systems.

What if I am developing something simple and I can easily set up my e

11条回答
  •  [愿得一人]
    2020-12-10 04:28

    Assuming that you want to automate this, the most important thing is that you can programmatically generate your initial condition. It sounds like that's the case, and even better you're testing real world data.

    However, there are a few drawbacks:

    Your real database might not cover certain conditions in your code. If you have fake data, you cause that behavior to happen.

    And as you point out, you have a simple application; when it becomes less simple, you'll want to have tests that you can categorize as unit tests and system tests. The unit tests should target a simple piece of functionality, which will be much easier to do with fake data.

提交回复
热议问题