creating dummy databases

Discussion of testing theory and practice, including methodologies (such as TDD, BDD, DDD, Agile, XP) and software - anything to do with testing goes here. (Formerly "The Testing Side of Development")

Moderator: General Moderators

Post Reply
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

creating dummy databases

Post by jmut »

Hi all.

I am making this application using relatively big DB...meaning lots of tables and stuff.


When I test some methods in my classes...for example if something is created or whatever...I check in the DB to see if there is record and the values are correct. that is how I assure my method works good.


The thing is....I want to make it possible so my test cases create dummy detabase with all tables and all required...and when finished drop it (you know..return to same state after test).
The reason for this would be that I will be able to run the tests on live environment (not deleting any live data...or interfereing with it).

Well...the problem that comes here...how you set priviliges and all to crete the database and everything. Or is maybe database created in advance...and just tables are recreated droped.
Thanks...hope what I said make some sense :)
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

If you can create a database with another tool at the moment, then chances are you have a valid user with those priveleges... The easiest approach (especially on shared hosting where a user may not be able to create DBs outside a control panel) is just to create a database and constantly re-use it for testing purposes.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

Maugrim_The_Reaper wrote:If you can create a database with another tool at the moment, then chances are you have a valid user with those priveleges... The easiest approach (especially on shared hosting where a user may not be able to create DBs outside a control panel) is just to create a database and constantly re-use it for testing purposes.
It is dedicated stuff. have control on everything.
For now I guess most usable will be creating `database_testcases` database... and lest testcase user or whatever to create and drop tables within, simulating real DB structure and all.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

I have a separate schema for unittests...

- Every method is prepended with a transaction start..
- And appended with a transaction rollback.. .

This way, every test runs in a clean environment.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

timvw wrote:I have a separate schema for unittests...

- Every method is prepended with a transaction start..
- And appended with a transaction rollback.. .

This way, every test runs in a clean environment.
I am trying to address different problem I think :). The idea is when you finish a test to return to the same state as you were before starting it..right?

So I will have to delete the data from the tables actually. I want to completely isolate test cases from live data for example...so no broblems occure.
Anyhow think I found a plausable and workable solution.
Post Reply