I love the idea of DBFit (being able to run tests against every database system under the sun) but have found it very challenging to get up and running. There is documentation but it seems to assume a level of familiarity with FitNesse that I definitely did not have. The primary hurdle for me was getting the SQL Server JDBC drivers set up for DBFit and then creating the connection string in the right format.
Using the steps below you will be able to connect to a specific SQL Server database on a named instance using integrated security. The code below will then run a quick test, returning the word “test” in a column called “x”.
Unzip the dbfit zip somewhere on your disk, and then run startFitnesse.bat (just double-click it). A command window will open similar to this:
The next step is to create a very simple test to ensure we can connect to our SQL Server and run a quick query.
Enter the following URL into your web browser:
This will bring up a blank page (DBFit/FitNesse are based on wiki style logic where if there is a reference to a page that doesn’t exist it is assumed you will create it). The blank page looks like this:
Cut and past the following code into the window on the page, customizing it to match the server and database name in your environment.
!path lib/*.jar !|dbfit.SqlServerTest| !|Connect|jdbc:sqlserver://theservername\theinstancename;integratedSecurity=true;databaseName=thedatabasename| !|Query| select 'test' as x| |x| |test|
Make sure to choose TestPage from the drop down and click the save button at the bottom of the page (see green arrows below).
If you followed the directions closely the next screen you’ll see will look like the screen shot below and include a “Test” button on the top menu.
Click the “Test” button and you should get a green light verifying you successfully connected to your SQL Server and executed a query!
If you didn’t get the green light work back through the steps above and ensure you didn’t miss any steps. If you ran into any issues feel free and post the error in the comments and hopefully myself or another member of the community will be able to help!