Options

Save test code

Hi

I have a problem when testing this Product. It seems that I cannot save code in my newly created test.

I try to put it in the bottom of the standard text. and save it. But when I edit the test it's only the standard text left, my code is gone.

USE [xx]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO -- Comments here are associated with the test. -- For test case examples, see: http://tsqlt.org/user-guide/tsqlt-tutorial/

ALTER PROCEDURE [CreateNewCx].[test 12]

AS BEGIN

--Assemble

-- This section is for code that sets up the environment. It often

-- contains calls to methods such as tSQLt.FakeTable and tSQLt.SpyProcedure

-- along with INSERTs of relevant data.

-- For more information, see http://tsqlt.org/user-guide/isolating-dependencies/

--Act

-- Execute the code under test like a stored procedure, function or view

-- and capture the results in variables or tables.

--Assert

-- Compare the expected and actual values, or call tSQLt.Fail in an IF statement.

-- Available Asserts: tSQLt.AssertEquals, tSQLt.AssertEqualsString, tSQLt.AssertEqualsTable

-- For a complete list, see: http://tsqlt.org/user-guide/assertions/

EXEC tSQLt.Fail 'TODO:Implement this test.'

END;

MY CODE IS HERE BUT GONE NEXT TIME I TRY TO EDIT THE TEST 

Tagged:

Answers

  • Options
    Alex BAlex B Posts: 1,133 Diamond 4
    Hi @Fredrik_Borg1

    When you say "save it" do you mean that you are saving the script from SSMS or are you running the ALTER PROCEDURE code?  What does your code contain and why are you not including this in the body of the test procedure?

    I've just done a quick test and if I edit an existing test and add 'SELECT 1;' after the END; statement and then run the procedure it correctly saves the 'SELECT 1;' at the end. 

    This does however highlight a code analysis entry for the ALTER PROCEDURE that the procedure body is not enclosed in BEGIN / END block.

    If it were anything CREATE or ALTER statement you would have to split it off into it's own batch (i.e. after another GO statement) since stored procedures have to be the only thing in the batch and this would cause it to be separate from the test procedure and so would not appear when you edit the test.

    Kind regards,
    Alex


    Product Support Engineer | Redgate Software

    Have you visited our Help Center?
Sign In or Register to comment.