Faculty of Engineering and Mathematical Sciences 
Not logged in (login)

help3403


This forum is provided to promote discussion amongst students enrolled in Agile Web Development (CITS3403).
 
Options:
RSS cloud
Jump to:

Unittest permanently modifies database?

1 of 419 articles shown, currently no other people reading this forum.
photo
From: Alan C.
Date: Fri 22nd May, 4:30pm
Actions: 
        Login-to-reply
Hi, I wanted to clarify database behaviour that I'm seeing when running tests.

I've built my files as demonstrated during last week's workshop. It seems that when I 
register a user into the test database, then run a system test which involves dropping 
all users in the setUp and tearDown methods, the original user is also removed. Is 
there some way to avoid this behaviour (i.e have the database restored to original 
state once the test finishes)? Or is this even supposed to happen in the first place?

It seems pretty dangerous that the database is permanently modified by the tests, 
especially if the db.dropall() is called. If someone forgets to switch from Config to 
TestConfig, then there's a risk of losing all your data and having to revert to an 
earlier commit or re-migrate your database.

Related articles

Unittest permanently modifies database? (all 3) RSS
├─ THIS   Fri 22nd May, 4:30pm, Alan C.
├─ reply 1   Sat 23rd May, 6:09pm, Akhil N.
└─ reply 2   Sun 24th May, 10:20am, Timothy F.
This Page


Program written by: [email protected]
Feedback welcome
Last modified:  8:27am May 24 2020