Executing tests outside SQL Test

hoytmhoytm Posts: 4 New member
We recently had a situation where a user executed a test through a regular execute statement instead of working through the SQL Test UI. The test involved faking tables. The test threw an error and the tables being faked were left in a state where they did not have their original name, forcing us to restore from a backup. The test itself looks ok. The big question here is whether it is expected unit tests always be run through the UI. 

Thank you!
Matt
Tagged:

Answers

  • Eddie DEddie D Posts: 1,803 Rose Gold 5
    Hi @hoytm,
    Thank you for your forum post.

    SQL Test is just a UI wrapper for the tSQLt unit test framework.  The actual tests created are Stored Procedures created in the database that a user adds to SQL Test.

    There is nothing in place to prevent the Stored Procedures from being executed outside of SQL Test.  Ideally you would want to run the tests with SQL Test / tSQLt framework, as each test within the tool will drop any objects it creates.

    Many Thanks
    Eddie 
    Eddie Davis
    Senior Product Support Engineer
    Redgate Software Ltd
    Email: support@red-gate.com
  • lp135lp135 Posts: 2 Bronze 1
    @hoytm when you said "regular execute statement" did you mean that you executed the tSQLt.Run stored proc & passed in the name of your test stored proc like this?

    EXEC [tSQLt].[Run] @TestName=N'[TestSchemaOne].[test The Number One Equals the Numeral One]'

  • hoytmhoytm Posts: 4 New member
    Yep, that's what I meant. Further review of the test revealed it had issues. I guess the morals to the story are 1) review tests that fake tables carefully before executing them and 2) execute within SQL test or at least have a rollback ready in case something goes bad.
Sign In or Register to comment.