I am new to using tSQLt and struggling a bit with the available assert functions. The tSQLt.AssertEmptyTable method is great, but how do you apply a "not" condition to this, i.e. I want to assert that a table contains data?
Is there a way to assert a "not" condition using tSQLt?
144 Views Asked by Chris Nachand At
1
There are 1 best solutions below
Related Questions in UNIT-TESTING
- How to write tests for classes with inheritance
- PHPunit call magic methods
- Convert IEnumerable to IObservable with variable Period
- How to a run specific code before & after each unit test in Python
- Unit testing a class A that derives from an abstract class B
- Is there another way to unit test business logic in mvc
- Some of my tests show prepended with junit.framework
- Selenium Driver Service not found exception
- Can not convert from Class<PowerMockRunner> to Class<? extends Runner>
- AngularJS Unit Testing - multiple mocks and providers
- How to use Sinon.js FakeXMLHttpRequest with superagent?
- Get Mock with AutoMock.Create<>()
- Mock service that takes unitOfWork in constructor
- Cleanest method for creating a pytest test fixture that takes in dynamic text data
- g++ 5.1.0 not building project, clang shows unknown error
Related Questions in TSQLT
- How do I rename a tSQLt test class?
- How to convert datetime fileds to UTC Datetime for existing data in the database?
- Msg 8114, Level 16, State 5, Line 3 Error converting data type varchar to float
- tSQLt, triggers and testing
- tSQLt.RunAll returns 0 test cases but tSQLt.Run <schema name> works
- tSQLt - How to do a unit test on code in an error Catch block of code
- How to view test results in tSQLt?
- Get missing columns from a list of expected columns in a table
- How to ROLLBACK a transaction when testing using tSQLt
- code reuse tsqlt / sql test
- tSQLt - Install failed
- Is there a way to assert a "not" condition using tSQLt?
- Can I integrate Redgate SQL Test directly with teamcity to get code coverage
- Line vs Statement coverage in SQL Cover
- TSQLT Asserting stored procedure column names
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
That depends on what you actually want to test. Do you want to validate the content of the rows and columns in that table or just that it has one or more rows?
If the former, then tSQLt.AssertEqualsTable will allow you to compare the contents of one table (e.g. a #expected table populated with the values you are expecting) with the table under test
EXEC tSQLt.tSQLt.AssertEqualsTable '#expected', 'my_table';. One useful feature of this assertion is that only the columns in #expected are validated. So if #expected has ten columns but my_table as twelve, only the contents of those ten columns are checked, the other two will be ignored by this assertion. This can be useful, for example, when those two columns are auto-populated and so harder to test e.g. an IDENTITY column and a GETDATE() default. Obviously, if #expected has columns that do not exist on my_table the test will fail anyway.If you just want to check that there is any data at all in the table you can do something like
IF NOT (SELECT COUNT(*) FROM my_table) > 0 EXEC tSQLt.Fail 'my_table contains no data'