-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added tSQLt.DropAllClasses.ssp #13
base: main
Are you sure you want to change the base?
Conversation
This procedure runs DropClass on all schemas that are marked with a tSQLt.TestClass extended property. This can be used to easily reset your development environment, especially for those of us who make heavy use of query shortcuts (like RunAll) in lieu of GUI tools.
Nick, thanks for the submission. Could I ask you to do the following changes:
|
@mbt1 - Thank you for the advice, Sebastian! I've modified the ssp to use that view — silly that I didn't go looking for it before. I ran into some trouble when writing tests; SQL Server 2012 would not let me create a stored procedure with raw Also, I haven't written a ton of tests using SpyProcedure yet, so I'm happy to receive feedback on those if you have any comments. |
Thanks for the quick turn around. The tests look good. But, I am seeing two anti-patterns:
You can solve both issues by doing a The other thing you could consider is to load #expected from the faked TestClasses view to not repeat the same insert statement twice. But that is a matter of taste. I always try to remove as much duplication as possible without hampering readability. The final note, also a matter of taste, I don't like the SetUp functionality. I prefer to be able to see what is going on when looking at a test, without having to hunt down if there is a SetUp procedure. But you also don't want to repeat that code in every test, particularly as you might have to add other fakes or spies as the procedure under test evolves. The pattern I use is to write my own setup procedure and call it something like TestClass.FakeAndSpyAllObjects and then call it explicitly in all test. A little more clarity - bought with a little more duplication. It also makes dealing with that odd test that requires a different setup easier; something I run into quite often. |
@mbt1 The feedback is much appreciated! Is this more what you had in mind? I agree about SetUp — I just got bitten by that in one of my own projects, and I like your idea of an explicitly called setup procedure to aid readability of each individual test. I decided to just bring the two fake/spy calls into each test here since it's not an overly large bit of material. |
This procedure runs DropClass on all schemas that are marked with a tSQLt.TestClass extended property. This can be used to easily reset your development environment, especially for those of us who make heavy use of query shortcuts (like RunAll) in lieu of GUI tools.
I've included some tests and added to the buildorder.txt file, but I haven't tested a full project build — not really sure how I would go about doing that anyway.