Unit Testing Destructive Methods -


While doing unit testing on the model, and database-altering methods / functions, what is the best method or mentality for unit testing ? For example, in a model, there is no testable behavior other than passing / failing a "published" function, and in the case of passage, it modifies the database best practice or approach?

The current tests will have to be mirror the current database before testing, and simply have to change the database selection in my unit test file. Thanks for your suggestions.

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

  • Business logic will be executed against a duplicate database (repository mock)
  • Checks for testing whether the business logic has actually told the repository-delete method.

    If you want to test integration with business logic and database

    • open a database transaction
    • via SQL Add data to the database
    • Execute the business logic, which only destroys the data
    • Verify that the database does not have much in the database (via SQL)
    • Rollback database transactions.

      Update:

      If you are using .NET, then you get Java

Comments