Skip to content
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

Question about tSQLt.Fail design #203

Open
ay-azara opened this issue Jun 24, 2024 · 0 comments
Open

Question about tSQLt.Fail design #203

ay-azara opened this issue Jun 24, 2024 · 0 comments

Comments

@ay-azara
Copy link

ay-azara commented Jun 24, 2024

Hey, this isn't really an issue and I think I already know the answer but figured I'd ask anyway.

The code below fails if you call something like tsqlt.AssertEquals(0, 1, 'Fail message') outside the test runner. I ran into this while debugging some tests interactively; create some temp code, select code, execute code type stuff.

INSERT INTO #TestMessage(Msg)
SELECT COALESCE(@Message0, '!NULL!')
+ COALESCE(@Message1, '!NULL!')
+ COALESCE(@Message2, '!NULL!')
+ COALESCE(@Message3, '!NULL!')
+ COALESCE(@Message4, '!NULL!')
+ COALESCE(@Message5, '!NULL!')
+ COALESCE(@Message6, '!NULL!')
+ COALESCE(@Message7, '!NULL!')
+ COALESCE(@Message8, '!NULL!')
+ COALESCE(@Message9, '!NULL!')
+ @WarningMessage;

The table is created by tSQLt.Private_RunTest_TestExecution so I assume the expectation is that you'd never run tsqlt procs without the test runner but would there be a problem if tsqlt.Fail checked for the table and created it if it didn't exist as a fallback? It'd be cool if RAISERROR included the failure message but again my usage is outside the norm so I'm probably barking up the wrong tree :)

   IF OBJECT_ID(N'tempdb..#TestMessage') IS NULL
	CREATE TABLE #TestMessage(Msg NVARCHAR(MAX));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant