Testing a module with tSQLt on computed columns

I wrote several tests of the tSQLt database modules (via the Red Gate SQL Test) in procedures that called tables containing (persistent) computed columns recently, and note that if I use FakeTable SP, I find that the computed columns are not filled ( they are evaluated as null). The computed column is the key to the test, so I cannot just ignore the column in the test, and I would prefer not to duplicate the logic.

I evaluate the results using tSQLt.AssertEqualsTable SP, and therefore want the column values ​​to be the same in both.

In practice, Ive worked around this, not using FakeTable, but using (partially) rolling back transaction transactions at the end of the test (for the blog post http://sqlity.net/en/585/how-to-rollback-in-procedures/ ) or explicitly deletes test values.

I am sure there should be a better way to code this test and welcome any suggestions.

+5
source share
2 answers

. . , . , , . FakeTable , .

( ) , . FakeTable. . @ComputedColumn EXECUTE tSQLt.FakeTable 1. (http://tsqlt.org/user-guide/isolating-dependencies/faketable/)

Btw, - . tSQLt . , , , .

+4

tSQLt: http://groups.google.com/group/tsqlt

FakeTable.

:
EXEC tSQLt.FakeTable 'dbo.tst1', @ComputedColumns = 1;
EXEC tSQLt.FakeTable 'dbo.tst1', @Defaults = 1;

.

+3

All Articles