Hi, i want to know how to connect the database during testing a application(databse may be Oracle,sql server or any..) if possible i want codes for connecting the databse and other testing related stuff
The first and most important thing to note is that as soon as you add a database into your testing it makes the whole thing slower and more complicated. I strongly recommend that you design your code and your tests to test with "immediate" data for as long as you can, then use a mock database for as long as you can. Only when there is no other way consider testing against a real database. You will find that database tests are slow to set up and tear down, you will need to write lots of code to ensure that the right data is in the database before and after your tests, and you will probably find that other people sometimes "break" your tests by changing the data or structure of the db. When you do, finally, find you have to test the database access, try and isolate the database tests so that each database API (i.e. each SQL query, each stored procedure call etc.) is tested independently and is just assumed to be correct by the rest of your code. That's probably not quite what you were asking for, but has it helped?
Yeah, what he said. I've got a set of unit tests (200+ tests, 1,000+ assertions) that runs in less time than it takes to get a database connection. Check out Mock Objects for ways to avoid testing aginst a database.
Jon
A feeble attempt to tell you about our stuff that makes us money
a bit of art, as a gift, the permaculture playing cards