Integration Testing best practices

后端 未结 5 412
隐瞒了意图╮
隐瞒了意图╮ 2020-12-24 03:42

Our team has hundreds of integration tests that hit a database and verify results. I\'ve got two base classes for all the integration tests, one for retrieve-only tests and

5条回答
  •  我在风中等你
    2020-12-24 04:26

    Have you done any measurements (using timers or similar) to determine where the tests spend most of their time?

    If you already know that the database recreation is why they're time consuming a different approach would be to regenerate the database once and use transactions to preserve the state between tests. Each CUD-type test starts a transaction in setup and performs a rollback in teardown. This can significantly reduce the time spent on database setup for each test since a transaction rollback is cheaper than a full database recreation.

提交回复
热议问题