Hello,
My test case does not achieve 100% code coverage because the CATCH block in the procedure is not being executed during the test. To address this, I wrote a failure scenario intended to trigger the CATCH block. However, the object under test does enter the CATCH block as expected so the test case does not succeed. so used the below tsqlt framework syntax but my test case still not working.
following syntax:
Try1:
SET @expected = 'column does not allow nulls. UPDATE fails.'
EXEC tSQLt.ExpectException @ExpectedMessagePattern = '%column does not allow nulls. UPDATE fails.%', @ExpectedSeverity = NULL, @ExpectedState = NULL
Try2 :
SET @expected = 'column does not allow nulls. UPDATE fails.'
EXEC tSQLt.ExpectException @ExpectedMessagePattern = '%column does not allow nulls. UPDATE fails.%', @ExpectedSeverity = NULL, @ExpectedState = NULL
Try3:
EXEC tSQLt.ExpectNoException @Message ='Cannot insert the value NULL into column ‘’labelStatusId'', table ‘’localdb.dbo.Label''; column does not allow nulls. UPDATE fails.'
Kindly share the solution to resolve
Thanks,
Hello,
My test case does not achieve 100% code coverage because the CATCH block in the procedure is not being executed during the test. To address this, I wrote a failure scenario intended to trigger the CATCH block. However, the object under test does enter the CATCH block as expected so the test case does not succeed. so used the below tsqlt framework syntax but my test case still not working.
following syntax:
Try1:
SET @expected = 'column does not allow nulls. UPDATE fails.'
EXEC tSQLt.ExpectException @ExpectedMessagePattern = '%column does not allow nulls. UPDATE fails.%', @ExpectedSeverity = NULL, @ExpectedState = NULL
Try2 :
SET @expected = 'column does not allow nulls. UPDATE fails.'
EXEC tSQLt.ExpectException @ExpectedMessagePattern = '%column does not allow nulls. UPDATE fails.%', @ExpectedSeverity = NULL, @ExpectedState = NULL
Try3:
EXEC tSQLt.ExpectNoException @Message ='Cannot insert the value NULL into column ‘’labelStatusId'', table ‘’localdb.dbo.Label''; column does not allow nulls. UPDATE fails.'
Kindly share the solution to resolve
Thanks,