DbFit


I'd like to use DbFit with database X (which is currently not supported). Is that possible?
Implementing support for a new database takes less than one working day, if you know your way around the database internals. Just implement a new DbEnvironment variant and fire away. If you can provide a test database and one person who can help with database metadata extraction, please contact me and I'll help with implementing support for your database.

I need to insert null values to several columns, but I get an error message.
In FitNesse, empty cell generally means "print the current value, don’t test". That is why you get the error message 'Cannot use input parameters as output values. Please remove the question mark after '. Use the keyword NULL to insert nulls.

When I try to insert (or execute a procedure), DbFit complains that it "Cannot read columns/parameters for object". What's wrong?
There are two possible causes of this problem:
  • The first is that you misspelled the procedure or table name (it is obvious, but people keep reporting problems caused by this, so I'd like to suggest double-checking that first). Keep in mind that DbFit is executing under the privileges of the user that you supplied in the Connect command, so it may need a schema prefix to see your objects.
  • The second possible cause is that the current user does not have access to table or procedure metadata.

Does DbFit require any special database privileges?
DbFit generally goes not require any special privileges for the database. The only important thing is that the user whose credentials you are using to run the test pages has at least read-only access to the schema meta-data. For MySql, that means select grants on mysql.proc and information_schema.columns tables. For Oracle, that means access to all_arguments, all_tab_columns and all_synonyms. For SqlServer, that means access to sys.columns and sys.parameters tables.

Does DbFit support VARBINARY columns?
Yes, and it treats them as arrays of bytes. You can use the standard FitNesse syntax for byte arrays (comma-separated list of values), or you can use the 0xHEXDIGITS syntax if you activate the byte array handler. |CellHandlerLoader| |Load|dbfit.util.ByteArrayHandler|

My stored procedure returns a result set. How do I use it?

In Oracle, you can store the REF CURSOR output parameter into a variable (using <<varname) and then execute a query with that variable:

|Query|<<varname|

With SQL Server, there are no typically output arguments, but a stored procedure just opens a cursor. You can use the Query table directly against it. If you would like to use a parameter, put exec before the procedure name:


|set parameter|hm|3|

|query|exec listusers_p @hm|
|name|username|
|user1|user name 1|
|user2|user name 2|
|user3|user name 3|

DbFit says that my VARBINARY is System.Byte[]
You see System.Byte[] because that is how .NET prints a byte array. The object should have been stored correctly as a byte array, and you should be able to use 0xHEXDIGITS syntax for comparisons. See BinaryTests acceptance test for examples.

Does DbFit support GUID columns?
Yes, but you may need to activate that support manually. DbFit has a non- standard extension for FIT.NET which allows it to "understand" GUID fields. That is being implemented now in the standard FIT.NET test runner, so you may not need to load it manually in the future. In any case, put this table in your test to load the GUID handler:
|CellHandlerLoader|
|Load|dbfit.util.GuidHandler|    
This table should come below the test type definition (below SqlServerTest).

DbFit complains about an unsupported type. What's wrong?
To handle types properly, DbFit requires a bit of additional information that does not come from typical database driver meta-data. That is why there is some small amount of work involved in supporting each column type. You can see a list of supported data types for each database server in the AcceptanceTests suite. If you are using a column/parameter type that is not there, then no one asked for that yet. Please contact me and I'll be happy to extend DbFit to support that type.

How can we use Windows-integrated authentication?
Instead of calling connect with three or four separate arguments, call it with just one argument and specify the full .NET or JDBC connection string. If you are a database develeoper and don't know about those things, ask a .NET or Java developer in your organisation to help you out.

DBFit complains about invalid fixtures/methods
If you want to use DbFit in flow mode, then DbFit test name should be the first table on the page - not even imports, cell handler loaders or any set- up can come before it. If you want to use some other fixture to control the flow, then use DbFit in standalone mode.

Why does DbFit not see the time portion of my Date fields?

This issue affects Oracle users on the Java version of DbFit. Oracle's JDBC driver strips the time from Date columns since version 9, so no amount of magic on the client side can fix that. see Oracle JDBC FAQ1 for more information.

In the JDBC FAQ, Oracle suggests setting -Doracle.jdbc.V8Compatible="true" to map dates to timestamps. That should instantly solve your problem, but I don't know what else is triggered by that flag. If you want to experiment, change the batch file that starts FitNesse and add that before the FitNesse class name.


DbFit complains about registering a SQL Server driver
This issue affects SQL Server users in the Java version of DbFit, and the message displayed on the screen after the Connect command is Cannot register SQL driver com.microsoft.sqlserver.jdbc.SQLServerDriver. You need to download Microsoft SQL Server JDBC driver from their site, it is not open- source and cannot be distributed with DbFit. Deploy the JAR in the same folder as dbfit-XXX.jar. If you specify the full JDBC connection string explicitly, use Microsoft’s driver in JDBC URL. DbFit does not support 3rd party SQL Server drivers at the moment.