How to development Database for testing

Hi,

i want to use development database for my testing purpose.
The problem is with, when test cases are run, it deletes the data before
and after the test. but i dont want the data to be deleted.
how to do this.

Rajkumar S. wrote:

Hi,

i want to use development database for my testing purpose.
The problem is with, when test cases are run, it deletes the data before
and after the test. but i dont want the data to be deleted.
how to do this.

Hi Rajkumar,
You can duplicate your development database as testing database and
specify the same in database.yml test environment. By doing this you
will get the desired result without loosing data from development
database.

Thanks,
Anubhaw

Anubhaw P. wrote:

Rajkumar S. wrote:

Hi,

i want to use development database for my testing purpose.
The problem is with, when test cases are run, it deletes the data before
and after the test. but i dont want the data to be deleted.
how to do this.

Hi Rajkumar,
You can duplicate your development database as testing database and
specify the same in database.yml test environment. By doing this you
will get the desired result without loosing data from development
database.

Thanks,
Anubhaw

Hi,

But i don’t want to use seperate databases for testing and development .
i need to use single database only.how to do this by using single
database

Rajkumar S. wrote:

Hi,

i want to use development database for my testing purpose.

No you don’t. The point of a test database is to have something that
your tests can run against without messing with your dev data.

The problem is with, when test cases are run, it deletes the data before
and after the test. but i dont want the data to be deleted.

Yes you do. Tests must start from a known state, or they will not be
reliable.

how to do this.

Don’t. It’s a terrible, horrible, dangerous idea. Don’t even consider
it.

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone

Marnen Laibow-Koser wrote:

hi,
May be but i need it to use single development database for both
enviroments

stephenallred wrote:

On Aug 17, 7:54�am, Rajkumar S. [email protected] wrote:

May be but i need it to use single development database for both
enviroments

Why?

Why indeed? That’s a BAD, DANGEROUS practice.

Best,
–Â
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Sent from my iPhone

On Aug 17, 7:54 am, Rajkumar S. [email protected] wrote:

May be but i need it to use single development database for both
enviroments

Why?

Rajkumar S. wrote:

Marnen Laibow-Koser wrote:

hi,
May be but i need it to use single development database for both
enviroments

Rails makes the right things to do very easy, and if you stray outside
that, well you made a conscious decision to go that route, and bear the
consequences.

You are using automated testing aren’t you?

You are keeping your tests up to date with the code and data changes
you make in your development database on an ongoing basis?

You really need to look into some automated testing tools available for
Rails to do this with any kind of replicability and efficiency.

If you absolutely, positively, against-all-reason-and-recommendation
have to use the same database for dev and test, I would still not do
exactly that.

I’d suggest you use sqlite for your development database, and copy your
development.sqlite3 file to test.sqlite3 before running your tests, each
and every time.

Take a look at some Rails testing resources -

  • take a look at the fixtures part.

I can’t think of a reason not to have a separate testing database or
to try and run tests on the dev db, unless you are trying to re-invent
the wheel and make your own test suite. I think quite a few of us have
had the experience of trying to build something, like unit tests, that
have in place several standard solutions already.