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

  • ExpectException
  • ExpectNoException
Share and Enjoy:
  • FacebookFacebook
  • TwitterTwitter
  • LinkedInLinkedIn
  • RedditReddit
  • StumbleUponStumbleUpon
  • TechnoratiTechnorati
  • PrintPrint
2 comments
  Livefyre
  • Get Livefyre
  • FAQ
Sign in
+ Follow
Post comment
 
Link
Newest | Oldest
James Rushing
James Rushing 5pts

Throughout this document you say:

to clarify the test’s intend

it should be:

to clarify the test’s intent

@sqlity
@sqlity moderator 5pts

@James Rushing  Thanks for noticing. I found and fixed two places. Did you notice more?

Navigation

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

Links

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

Sponsors

sqlity.net
redgate.com

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