Unit testing of destructive methods

When doing unit tests on models and methods / functions of modifying a database, what is the best methodology or thinking for unit testing? For example, the publish function in the model has no test behavior, except for pass / fail, and in the case of transfer, it changes the database. Best practice or approach?

My current thoughts are to mirror the current database before testing and just change the database selection in my unit test file. Thank you for your suggestions.

+3
source share
3 answers

If you want to do unit test (= test in isolation):

  • business logic will run against a fake database (mock repository)
  • , - -.

- ,

  • sql
  • -, .
  • , ( sql)
  • .

Update:

.NET, ndbunit java dbunit

+6

xtunit, .net. , .

+1

... . , .

+1

All Articles