 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
Unit testing |
|
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 |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
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 |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
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 |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
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 |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
It's a good one. I'll try it, thanks.
|
|
Fri Jun 11, 2010 4:58 am |
|
 |
|
|
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
|
|
|