tSQLt - Database Unit Testing for SQL Server

Database Unit Testing for SQL Server

  • Home
  • Docs
    • Documents
    • Quick Start
    • Articles
  • Training
  • Downloads
tSQLt » Documents » Expectations » ExpectNoException

ExpectNoException

Syntax

tSQLt.ExpectNoException [ [@Message= ] 'supplemental fail message']

Arguments

[@Message = ] ‘supplemental fail message’
Optional. Supplemental information to clarify the test’s intent. This is displayed in case of a failure.

Return Code Values

Returns 0

Errors Raised

Raises a ‘failure’ error if any error is raised after it was called.

Result Sets

None

Overview

tSQLt.ExpectNoException marks the point in the test after which no error should be raised. tSQLt.ExpectNoException specifies that the intention of the test is to assert that no error is raised. Therefore the test will fail instead of error, if an error is encountered after tSQLt.ExpectNoException was called.

There can be only one call to tSQLt.ExpectNoException per test. However, a call to tSQLt.ExpectNoException can be followed by a call to tSQLt.ExpectException.

Examples

Example: Using tSQLt.ExpectNoException to assert that no error is raised

CREATE PROCEDURE PurgeTableTests.[test dbo.PurgeTableIfExists ignores not existing table]
AS
BEGIN
  EXEC tSQLt.ExpectNoException;
  EXEC dbo.PurgeTableIfExists @TableName='dbo.DoesNotExist';
END;
GO

See Also

  • ExpectNoException
  • ExpectException
Share and Enjoy:
  • FacebookFacebook
  • TwitterTwitter
  • LinkedInLinkedIn
  • RedditReddit
  • StumbleUponStumbleUpon
  • TechnoratiTechnorati
  • PrintPrint

Navigation

  • Join the conversation
  • Downloads
  • New Logo
  • Sponsors & Contributors
  • Release Notes
  • Articles
  • Training
  • How to get more out of tSQLt
  • Why you should use the tSQLt framework
  • Why you should unit test SQL Server Code
  • Full user guide
  • Documents
    • Quick Start
    • tSQLt Tutorial
    • tSQLt Keyboard Shortcuts
    • Test Creation and Execution
      • NewTestClass
      • DropClass
      • RunAll
      • Run
      • RenameClass
    • Assertions
      • AssertEmptyTable
      • AssertNotEquals
      • AssertObjectDoesNotExist
      • AssertEqualsTableSchema
      • AssertEquals
      • AssertEqualsString
      • AssertEqualsTable
      • AssertObjectExists
      • AssertResultSetsHaveSameMetaData
      • Fail
      • AssertLike
    • Expectations
      • ExpectException
      • ExpectNoException
    • Isolating Dependencies
      • FakeFunction
      • RemoveObjectIfExists
      • ApplyConstraint
      • SpyProcedure
      • FakeTable
      • ApplyTrigger
      • RemoveObject

Links

  • tSQLt on GitHub
  • tSQLt Mailing List
  • twitter hashtag (#tsqlt)
  • tSQLt tag on stackoverflow.com
  • SQL Server Community on Slack (#tsqlt)
  • #tSQLtLive on YouTube

Sponsors

sqlity.net
redgate.com

A sqlity.net llc Web Property. | ©2010 - 2020, All Rights Reserved. | Privacy Policy | Terms of Use