-
Notifications
You must be signed in to change notification settings - Fork 107
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
Easily preventable error: running faking sprocs outside of test's transaction #3
Comments
Actually, here's the code snippet we used to give ourselves some training wheels. IF @@TRANCOUNT = 0
BEGIN
RAISERROR('tSLQt.FakeTable called outside of a test session', 16, 10)
RETURN
END |
I will look into how to make this more safe for newbies. There are however people that use FakeTable outside of a transaction intentionally, and I don't want to break their tests. |
+1 for making the change tjlittle suggested. Increment the version number to mark it as a breaking change. |
+1 from me. We had a similar issue on a very large db and it took a whole day to resolve. It wasn't a noob mistake either, anyone can accidentally run an SP after a long tiring day, rather than running it using the tSQLt.Run proc |
I propose changing the function signature of FakeTable (and similar) to have an If you feel that is too disruptive, then perhaps a database-level setting in Would this change be accepted by the maintainers? |
@mbt1 @dennislloydjr is the proposed change above acceptable? |
Hello,
We're experimenting with tSQLt. So far we love it, except for one small issue. It's definitely a n00b mistake, but since it's so easily preventable we thought we'd suggest a solution to prevent it.
In one of our first experiments with tSQLt, one of our developers wanted to run a snippet of the test he was developing, so he outlined it in SQL Server Management Studio and hit F5. Unfortunately, there was a call to tSQLt.FakeTable in the outlined snippet.
Since we were new to the framework, all we knew was that all the data in our table was gone - we didn't even know what had caused it to disappear. It was a test system, and we had backups anyway, so no harm done - however our confidence in tSQLt was severely shaken until we were able to guess what had happened, and find our data by looking in the renamed objects table.
It would be nice if the faking/spying functions all had some protection code in them to detect if they were being run inside a test run, and raise an error before any changes were made. Something similar to
IF @@TRANCOUNT = 0 RAISERROR('tSLQt.FakeTable called outside of a test session', 16, 10)
perhaps?It's not that big of a deal, but I think it could help new users of the framework immensely.
Thanks for your consideration,
Travis Little
The text was updated successfully, but these errors were encountered: