SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Unit testing

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
Unit testing
Author Message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post Unit testing Reply with quote
I've just decided to try unit testing and I'm stuck with initialization. There are two options on the Initialize tab fore each test case : Test Data Generator Project and SQL code. What if both of those are set? Do they both apply? If so, which of them is run first?

By the way, it seems that if the script on Execute tab fails, the Cleanup is not run. Could you check that, please?
Thu Jun 10, 2010 7:59 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
Yes, both options can be used, they are independent. I believe the data generator runs first.

In case the Execute step fails, the Cleanup step is not run. This is done on purpose to leave the data changes, if any made, available for troubleshooting after the test case failure; and also to ensure that any test cases dependent on the outcome of the failed test, they fail too.
Thu Jun 10, 2010 11:09 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post Reply with quote
That is reasonable, and the data left can be of some use in debugging the script that failed, but there are some occasions when it will cause any further execution of corrected script to fail.

Is there a way to only execute the cleanup part? Besides commenting out both Initialize and Execute parts, I mean. Manually with a button or perhaps an option in the Initialize part that decides whether to execute Cleanup before Initialize?

May I use BEGIN TRANSACTION as Initialize and ROLLBACK TRANSACTION to Cleanup? I guess that won't work because the're in separate batches but I thought I'd better ask...
Thu Jun 10, 2010 12:56 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
Here is an idea: Unit tests can consist of one or more test cases. I suggest to use at least 3 test cases and set the initial test case to execute BEGIN TRAN and set the last test case in the same unit to execute ROLLBACK TRAN. If you set error handling at the unit test level to always continue after a failed test case, it should perform, as you want.
Thu Jun 10, 2010 7:03 pm View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2109

Post Reply with quote
It's a good one. I'll try it, thanks.
Fri Jun 11, 2010 4:58 am View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.