How do you unit test business applications?

前端 未结 6 1206
执念已碎
执念已碎 2021-02-19 07:05

How are people unit testing their business applications? I\'ve seen a lot of examples of unit testing with \"simple to test\" examples. Ex. a calculator. How are people unit tes

6条回答
  •  孤街浪徒
    2021-02-19 07:14

    It depends on what you're testing. If you're testing a business logic component -- then its immaterial where the data is coming from and you'd probably use a mock or a hand rolled stub class that simulates the data access routine the component would have called in the wild. The only time I mess with the data access is when I'm actually testing the data access components themselves.

    Even then I tend to open a DB transaction in the TestFixtureSetUp method (obviously this depends on what unit testing framework you might be using) and rollback the transaction at the end of the test suite TestFixtureTeardown.

提交回复
热议问题