Last post Aug 18, 2010 11:09 AM by lreddy
Aug 17, 2010 06:08 AM|misuk11|LINK
Im pretty new to NUnit and am beginning the process of setting up my tests. Some of these test involve a database, specifically checking a particular value against a value in a database and if its not greater than the last retrieved value, flag an error.
Whats the best way to test in this scenario ? should I write one value to a database then create another value thats out of sequence and run a database query ? This would involve putting a known value into the table, then running the query with another
There is no rollback attribute for nunit, so I gues using TransactionScope would work, that way I could return the database to a known state after the test. There tables have foreign keys so that means adding a lot of extra 'dummy' data first to some of
the other tables. Is this sort of 'testing' the best way ? I basically need to perform the test based on an existing data value and I guess this must be pretty standard stuff, so whats the best way ?
As I understand it, the tests should be self contained, so any data i insert into the database during the test should be removed afterwards, is this correct ? If so, it means I need to insert test data into 6 additional tables just to test one function,
then remove it after the test has completed, is this the normal way to to this ?
Aug 17, 2010 10:34 AM|ketan_al|LINK
Please refer following
hope this helps
Aug 18, 2010 11:09 AM|lreddy|LINK
You can use [TearDown] attribute for a method and rollback the transaction in the method implementation.
Use Assertion to test your scenario rollback will be done after every testFixture in this case.