Using WebTest & DbFit together

If you are testing a web application, there is a good chance that you will need to manipulate or verify some data in a database as part of your testing of the front end application.

It would seem obvious to use DbFit and WebTest on the same test, however you should be aware of a few things.

WebTest is a DoFixture, and DbFit can work in two modes, flow or standalone, you will need to use the standalone mode of DbFit when using DbFit with another fixture..

When creating the SetUp page for the suite of tests add the fixtures like this:


Note that there isn’t a gap between DatabaseEnvironment and Connect, they must be in the same table

You can also connect to DbFit with the Connect table.

Also remember that since you’re using standalone mode of DbFit, it wont rollback or commit, so you will need to use the following tables to commit or rollback transactions:



We use the WebTest fixture and DbFit together and it works very well for us. However we have also extended WebTest to include some SQL features in WebTest that allow us to do simple SELECTS and use the output to verify what should be on screen without breaking the flow of the test.

Please Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.