tsqlt - create separate database for unit testing
Asked Answered
S

2

10

I have started using tsqlt, and my question is it possible to have a separate database with just the testing stuff? (tables/sp's/assemblies etc).

This testing database will sit on the same instance as the actual/target database.

If I try to fake a table I get the following error:

FakeTable could not resolve the object name, 'target_db.dbo.Sometable'

Has anyone had any experience with this?

Thanks.

Showalter answered 21/11, 2012 at 15:1 Comment(1)
It doesn't seem to have as much activity as tsqlt, but TSQLUnit does allow you to keep a separate database for testing.Hartfield
E
10

As you discovered, this isn't currently possible as the mocking procedures don't accept three part names. This is something that's been covered at the User feedback forums of SQL Test (RedGate's product that acts as a front end to tSQLt) at : http://sqltest.uservoice.com/forums/140716-sql-test-forum/suggestions/2421628-reduce-the-footprint

Dennis Lloyd, one of the authors of the tSQLt framework wrote towards the end of that thread that support of a separate 'tSQLt' database was something they would keep under consideration.

Also a related issue of mocking remote objects at http://sqltest.uservoice.com/forums/140716-sql-test-forum/suggestions/2423449-being-able-to-mock-fake-remote-objects

I hope that helps,

Dave

Empale answered 23/11, 2012 at 7:46 Comment(0)
M
9

You can now do this, so long as the tSQLt framework is in the other database:

EXEC tSQLt.FakeTable '[dbo].[Position]';
EXEC OtherDB.tSQLt.FakeTable '[dbo].[PositionArchive]';

Source

This means that you can at least put your tests where you want them, though you have to install the framework in the actual database under test. Which is not perfect, but it's better.

Miguelinamiguelita answered 7/3, 2014 at 21:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.