Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unit Testing Strategy

Status
Not open for further replies.

russellbcopeland

Programmer
Apr 26, 2001
113
US
I am putting together a unit testing strategy (using mostly nUnit and VB.Net) and am looking for information on how to handle my data.

I will have processes that require testing that really need to have a standard set of data to go with the test. Problem is that the test will change the data and tests of other pieces of the system will change the data. It seems that I need to have some method of resetting to a baseline set of data before each test.

I suppose I could have a base set of data and reload it for each test group but that could really be very time consuming as I am dealing with a rather large amount of data.

Does anyone have any advice on this or know a good source of information (books, articles, sites, etc.) on how people handle this?
 
The last webcast I viewed on Test Driven Development stated that each test should be completely independent from the other tests. They suggested that if a test manipulates data from a database, the test itself should be responsible for inserting the data that will be manipulated, execute the procedure, then delete the data afterwards. I don't know how realistic that is in the real world though. I was on a project where we just didn't have that kind of access to the data. We ended up putting a scaled back version of the database on each developer's computer that they could restore from whenever they needed to run the tests. I'm also hoping there's a better way.

Adam

There are only 10 types of people in the world: Those who understand binary, and those who don't
 
One of the primary things I've always done for development is to create a test environment. A copy of the database on an old server, and a flag for test/prod mode to determine which network resources and database to use. Right now we have it tied to the build version (debug/release) as to which DB/resources it hits. But on an older system I worked on we used a loggon system that would route you to one or the other.

It's not as nice as having a complete testing tool set for injecting/testing/cleaning data like Adam suggested, but I've never been on a project with the time frame to build something like that. If we need a set chunk of data we will often back up the table/source file and manually overwrite the target test data for the test. It's a pita, but when you are on a super tight deadline, spending a week on creating developer tools can be hard.

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
ThatRickGuy said:
" ... super tight deadline, spending a week on creating developer tools ... "

phrased slightly differently:

me said:
"There is never enough time to do it right ... but ... there is always time to do it over"




MichaelRed


 
"There is never enough time to do it right ... but ... there is always time to do it over"

To refine:

"There is never enough time to do it right if there's enough to to only need to do it over a fraction of the time

Doing it right the first time will save you time and money in the long run. Keeping your leasing department on hold for 3 months will get you fired though. Often times in crunch schedules a lot of what gets done is "shoot from the hip" work. Sometimes it's dead on, most of the time it works, and sometimes, you stumble and blow your toes off. If you can shoot from the hip good enough to support your users in the short term, and work on tools for the long term, you'll be good to go.

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top