Prany
Prany

Reputation: 2133

TSQLT - Error while trying to fake a table

Hi I am pretty new for TSQLT Unit tests I am getting error while trying to create a fake table, any help is appreciated.

I have my dev project in one database and TSQLT in another database

EXEC tSQLt.FakeTable @TableName = '[AnotherDB].[dbo].[Table1]'

The error is

[Test].[test that checks the size] failed: (Error) FakeTable could not resolve the object name, '[AnotherDB].[dbo].[Table1]'. (When calling tSQLt.FakeTable, avoid the use of the @SchemaName parameter, as it is deprecated.)[16,10]{Private_ValidateFakeTableParameters,12}

Although this table does exist in another database, select * will work on this table. Also I have seen couple of posts but not clear what to do.

Upvotes: 0

Views: 1176

Answers (2)

Dmitrij Kultasev
Dmitrij Kultasev

Reputation: 5745

There is no native functionality yet for that, however I've created pull request in the tSQLt github repository that implements that feature. You can build the project by yourself, or you can use pre-build dacpac from my repo. In that dacpac you'll find official tSQLt objects + 2 my features (faking synonyms and improved way to fake the functions). You can check for fake function examples here

So, for your case, you need to create the synonym for that object and then mock it with the FakeTable in the same way you do for tables.

Upvotes: 1

Sebastian Meine
Sebastian Meine

Reputation: 11773

FakeTable cannot (yet) resolve objects in another database.

Upvotes: 0

Related Questions