Dennis's blog
Faking Views
Dennis - Tue, Nov 10 2009, 01:25
We've seen FakeTable in tSQLt in action in a few demos now. Did you know that you can use FakeTable to fake a view?
You use FakeTable on a table when you want to test a procedure (or function or view) that relies on a table. It prevents you from needing to concern yourself with all of the other constraints a table might have, such as foreign keys to other tables or not-nullable columns which have nothing to do with your procedure. This is particularly useful if you have a schema where many tables are interrelated through foreign keys because you can focus on the procedure you're testing instead of trying to create test data for dozens of unrelated tables.
Similarly, you would want to fake views.