• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Database connection for testing databse and the application

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
A feeble attempt to tell you about our stuff that makes us money
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic