Feb 28 2007

DbFit: Test-driven database development

Published by gojko

DbFit is a set of FIT fixtures which enables FIT/FitNesse tests to execute directly against a database. This enables developers to manipulate database objects in a relational tabular form, making database testing and management much easier then with xUnit-style tools. The library is free to use, released under GNU GPL.

Features | Download | Reference | Source code | Related resources
Why DBFit | Project goals | Q & A


Features

  • Regression testing for queries and SQL statements
  • Functional testing for stored procedures and functions
  • Automatic transaction control and various short-cuts to make writing test scripts easier and more efficient
  • Support for DB2, Oracle, SQL Server (java and .net versions), MySql 5 and Derby (only java)

For more details, see DbFit pages on fitnesse.info.


Why DBFit

After introducing FitNesse into a big .NET project, I found that we were still lacking test-coverage for a lot of DB (legacy) code, and that DB developers have a long feedback loop, so they were not really benefiting from TDD. FitNesse was a good solution because it enabled DB developers to write functional tests much easier than in pl/sql based unit testing libraries, and without getting Java developers involved to write those as JUnit tests. Although FitNesse is typically used for acceptance tests, the combination of FitNesse+DbFit filled the testing gap for our DB code with excellent results. In fact, as the natural DB interface is relational, FitNesse tables allow writing database tests much more efficiently than using function-centered unit testing libraries. For a more detailed view into the background of DbFit, see Fighting the Monster.


Project goals

  • Enable managing database state from FitNesse as an utility for integration tests involving databases, by .Net and Java developers
  • Enable the use of FitNesse for effective database acceptance and unit testing by DB developers (with no .Net/Java knowledge)

The first group mainly needs reusable fixtures which they can use, either directly on the page or embedded in their project-specific fixtures, and will not mind digging into a bit of Java/.Net code. But the other group must not be made to wait for Java/.Net developers to do effective TDD. So the project is taking a dual approach – developing test fixtures which will be reusable and extendable, but also developing one arch-test fixture which can control the connection, transactions and test flow in a fitlibrary flow mode. So Java/.Net developers can utilise the fixtures directly, and DB developers will be able to utilise the test fixtures through the over-arching fixture control.

See other FitNesse resources on this site


Q&A

For support and to send questions, comments and ideas, join the DbFit discussion group on google groups. Comments are no longer enabled on this page.


289 responses so far

289 Responses to “DbFit: Test-driven database development”

  1. sunil joglekaron 02 Mar 2007 at 10:54 am

    are you planning for a java version ?

  2. gojkoon 02 Mar 2007 at 11:53 am

    yes, that’s planned for the future. the first thing in the roadmap is SqlServer support and probably expanding the supported set of data types, then I plan to do a java version.

  3. Test Early » Getting Fit with .NETon 06 Mar 2007 at 9:52 pm

    [...] In related news – Gojko Adzic has also released DbFit, an extension of the Fit testing framework which allows database developers to write and automate functional and acceptance tests easily. [...]

  4. Mike Ramseyon 07 Mar 2007 at 10:55 pm

    Way cool!

    Just out of curiosity, how soon will support for SQLServer be available….

    –Thanks,
    –Mike Ramsey

  5. gojkoon 08 Mar 2007 at 6:42 am

    Sometime next week.

  6. Mark Rosson 13 Mar 2007 at 10:19 pm

    This looks great.

    I’ve just finished building my own test framework for SQLServer stored procedures using batch scripts, in large part because I was not comfortable extending FitNesse to handle the kinds of tests I wanted to build. Now, as I prepare to roll out my framework to my users, I find that you have done the heavy lifting.

    I’ve got a meeting tomorrow to discuss our next steps, so I am very interested in how the SQLServer port is coming along.

    Mark

  7. Dharmesh Baroton 13 Apr 2007 at 6:15 pm

    Is the DBFit for SqlServer available? Please let me know

    Thanks.

  8. gojkoon 22 Apr 2007 at 12:14 pm

    The project has been moved to sourceforge (see http://sourceforge.net/projects/dbfit) and the version with full SQL server 2005 support can be downloaded from there. Meanwhile, I laid out the roadmap for 1.0 release. I’m still cleaning it up, did not have too much time over the last month, but I expect to release 1.0 for .Net soon.

  9. Andres Almirayon 26 Jul 2007 at 4:29 pm

    How does DbFit relate to DbUnit? I’m aware that DbUnit has no Fit/Fitnesse integration but it has great support for importing/exporting data and asserting db state, just wondering =)

  10. gojkoon 26 Jul 2007 at 4:39 pm

    DBFit does not suffer from the object/functional-relational mismatch. It allows you to express tests in a tabular format, which comes much more natural for database objects. main aim of dbunit is to enable putting a database in a “known” state, but dbfit is aimed at full db regression testing (makes it very easy to test stored procs, for example)

  11. Dharmesh Baroton 31 Jul 2007 at 10:20 pm

    Have you released DBFit for .Net 2.0 or 3.0?

  12. Glen Weaveron 09 Aug 2007 at 3:54 pm

    I just went to SourceForge using the url in 8. above. The project is there, but it indicates that no file release packages have been defined. Is there a technical problem or has the project been disabled or…?

  13. gojkoon 09 Aug 2007 at 5:30 pm

    binary releases for .NET and Java can be downloaded from http://sourceforge.net/project/showfiles.php?group_id=191053

  14. Andy Jacksonon 20 Sep 2007 at 9:46 pm

    Do you plan to add support for binary data columns?

  15. gojkoon 20 Sep 2007 at 9:50 pm

    I generally add stuff when someone requests it, so why not. Nobody asked for binary data support yet – let me know exactly what you need and i’ll put it in.

  16. Andy Jacksonon 20 Sep 2007 at 10:54 pm

    I use binary data columns to store long hex strings like 0×865878C1DED639BC. When I use .Net apps to get records, these columns come back with a DataType of System.Byte[].

    When my FitNesse tables have these kind of hex strings as the expected result, it currently cause dbfit tests to throw exceptions:

    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.FormatException: Input string was not in a correct format.

  17. gojkoon 20 Sep 2007 at 11:15 pm

    FitNesse expects arrays to be specified as comma-separated lists, so you may try putting the value in in CSV format. Leave the field empty and re-run the test to check what fitnesse thinks it got in that cell. I can extend the parsing mechanism to read 0x… as a binary array if CSV is not an option for you. Send me a test case if you want me to do that.

  18. Andy Jacksonon 28 Sep 2007 at 4:36 pm

    The value that fitnesse thinks it has when it selects a binary value is “System.Byte[]“

  19. Sjuron 02 Oct 2007 at 10:07 am

    How difficult is it to set up dbfit to use other databases? I am thinking especially of hsqldb (in-memory database, http://hsqldb.org/)
    Is it more to it than implementing the interface DBEnvironment?

    If you publish some rough guidelines, I can try myself : )

  20. gojkoon 02 Oct 2007 at 10:20 am

    It’s just implementing a DBEnvironment and a new DatabaseTest implementation.
    See MySqlTest.java
    and
    MySqlEnvironment.java
    . to support standalone fixtures, also add a piece of code into
    DatabaseEnvironment.java
    to initialise the environment. That’s it for a rough guideline – don’t hesitate to yell for help :)

  21. Jim Bethancourton 10 Oct 2007 at 10:58 pm

    Hi Gojko,
    I found that the only way to execute no-param no-return Oracle Stored Procedures was with an Execute statement, such as the following

    |Execute| Begin Sproc; End;|

    Although you mention to have only one row for the special case where no parameters are passed to the procedure / function, I found that approach doesn’t work and wanted to share my workaround for the time being.

    Cheers,
    Jim

  22. gojkoon 14 Oct 2007 at 12:13 am

    Andy,

    I’ve changed the SQLServer DbFit implementation to support binary and varbinary (it was SQLServer, was it?), and i’ve also built in support for parsing 0x formatted hex strings into byte arrays. I’ll do a proper release soon, but the current build is on the following URL:

    dbfit-dotnet-current.zip

    you will need to load the cell handler manually to support the new parsing. See the example on the bottom of
    DotNet.AcceptanceTests.SqlServerAcceptanceTests.DataTypes

  23. Srinion 22 Oct 2007 at 8:43 pm

    Hi I have very simple SQL server 2005 stored procedue and when I ran the test code as shown below its giving me errors…Am I missing something here. Thanks for the help.

    –sql stored procedure
    create procedure [dbo].[get_ConnectString1]
    @atlasServer varchar(20),
    @connectStringOut varchar(200) output
    as
    set @connectStringOut = ‘test’
    select @connectStringOut ‘connectstring’

    – wiki test code

    !|Execute Procedure|get_ConnectString1|
    |AtlasServer|connectStringOut|
    |CS3SMDSEI32R||

    –errors

    Execute Procedure
    ——————————————————————————–

    System.NotSupportedException: Type DESC15 is not supported
    at dbfit.SqlServerEnvironment.GetDBType(String dataType) in W:\work\dbfit\dbfit\impl\dotnet\src\environment\SqlServerEnvironment.cs:line 136
    at dbfit.SqlServerEnvironment.ReadIntoParams(String objname, String query) in W:\work\dbfit\dbfit\impl\dotnet\src\environment\SqlServerEnvironment.cs:line 91
    at dbfit.SqlServerEnvironment.GetAllProcedureParameters(String procName) in W:\work\dbfit\dbfit\impl\dotnet\src\environment\SqlServerEnvironment.cs:line 45
    at dbfit.fixture.ExecuteProcedure.InitParameters(Parse headerCells) in W:\work\dbfit\dbfit\impl\dotnet\src\fixture\ExecuteProcedure.cs:line 116
    at dbfit.fixture.ExecuteProcedure.DoRows(Parse rows) in W:\work\dbfit\dbfit\impl\dotnet\src\fixture\ExecuteProcedure.cs:line 43
    at fit.Fixture.DoTable(Parse table)
    at fitlibrary.FlowFixtureBase.ProcessRestOfTable(Fixture theFixture, Parse theRestOfTheRows) get_ConnectString1
    AtlasServer connectStringOut
    CS3SMDSEI32R

  24. gojkoon 22 Oct 2007 at 9:00 pm

    Hi Srini,

    it complains about an unsupported type definition. Don’t really know why, but if you could run the following query and send me the results, I will be able to fix it.

    select p.[name], t.[name] as [Type], p.max_length, p.is_output, p.is_cursor_ref from sys.parameters p inner join sys.types t on t.system_type_id = p.system_type_id
    where p.object_id = OBJECT_ID(@objname)
    and t.[name] <> ’sysname’

    objname parameter should be get_ConnectString1

    is it possible that you have another procedure by the same name, or some other db object called get_ConnectString1?

  25. Sharon Cutteron 29 Oct 2007 at 9:45 pm

    I have two questions about DbFit with Oracle:

    1. In general our packages are stored in a central schema, but when developers are working, they bring the packages into their own schemas and rely on public synonyms to “see” the central packages. For example, all packages will be in schema DEV, but the package I’m working on will also be in my SHARON schema. But DbFit can’t resolve any package names that are in the DEV schema unless I explicitly call it by DEV.package_name.proc_name. I’d like the database tests to be usable by developers while working and as a full-blown regression suite, so I’d really like to have the transparency of synonyms.

    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
    at System.ThrowHelper.ThrowKeyNotFoundException()
    at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
    at dbfit.fixture.ExecuteProcedure.InitParameters(Parse headerCells) in W:\work\dbfit\dbfit\impl\dotnet\src\fixture\ExecuteProcedure.cs:line 121
    at dbfit.fixture.ExecuteProcedure.DoRows(Parse rows) in W:\work\dbfit\dbfit\impl\dotnet\src\fixture\ExecuteProcedure.cs:line 43
    at fit.Fixture.DoTable(Parse table)
    at fitlibrary.FlowFixtureBase.ProcessRestOfTable(Fixture theFixture, Parse theRestOfTheRows)

    2. Some of our procedures take arrays as input parameters. DbFit errors saying that the pl/sql type is not supported. Any plans for array support?

    Thanks!

    –Sharon

  26. Marisaon 02 Nov 2007 at 7:40 pm

    OK…so thank you for all of your info about FitNesse – our QA team has implemented FitNesse thanks to the information found on your site (which is the best we have found so far).

    I am eager to get DBFit working – I can connect to our SQL DB but I keep getting the following dbfit error:

    System.MissingMethodException: Method not found: ‘fit.ICellHandler fit.CellOperation.GetHandler(fit.Parse, fit.Accessor)’.
    at dbfit.AbstractDataTableFixture.IsMatch(Parse row, DataRow d)
    at dbfit.AbstractDataTableFixture.FindMatchingTableRow(Parse row, DataTable table)
    at dbfit.AbstractDataTableFixture.DoRows(Parse rows)
    at fit.Fixture.DoTable(Parse table)
    at fitlibrary.FlowFixtureBase.ProcessRestOfTable(Fixture theFixture, Parse theRestOfTheRows)

    Can’t wait for the fix/help!

  27. gojkoon 02 Nov 2007 at 10:08 pm

    Marisa,
    it seems that you are using an incompatible version of FIT.NET. Can you confirm that you are using the latest binary version (1.3)? Maybe try to use the one from Dbfit dbfit-complete package from sourceforge.

  28. Denison 18 Nov 2007 at 8:51 pm

    I have a SQL Server 2005 procedure that returns 40 or so rows.
    I would like to test the stored proc logic. It has 5 input parms but 0 output parms
    I have predefined data for it so I expect the same results every time
    What dbfit fixture can I use? Here is example

    !|Execute Procedure|srd_Stock_Stats|
    |@ReportDate|@PKPPRD_GroupingTypes|@PKPPRD_Groupings|
    @PKPPRD_Levels|@PKSCC_StockTypes|@PKPPRD_EarnTypes|@TopXDivision|@TopXStock|
    |3/31/2006|2|2|6|1|0|0|0|
    |GroupingName|Stock|Week1|Week2|Week3|Week4|||
    |OIL|NULL|-/-|83%/92%|100%/100%|100%/81%|||
    |OIL|Shell|-/-|83%/92%|100%/100%|100%/81%|||
    |CONSUMER|NULL|-/-|100%/53%|71%/71%|100%/86%|||
    |CONSUMER|Target|-/-|100%/53%|71%/71%|100%/86%|||

  29. gojkoon 19 Nov 2007 at 12:59 am

    Hi Denis,

    How does the procedure return the results? does it open a cursor? If so, that functionality is not yet supported for SQL Server, but if you are willing to help with testing, I can write the support. Another way to do it would be to write a new utility test proc that stores the results into a temp table, and then query that temp table after procedure is executed.

    btw, you don’t need the @ before param name.

  30. Denison 19 Nov 2007 at 1:16 am

    Hi Gojko

    The sql stored procedure is something like this
    It declares a temp variable table x and stores info into from another stored proc.
    Through alot of SQL, joins and other complex logic the data in that temp variable table is
    selected in the stored proc like so
    select GroupingName,Stock,Week1,Week2,Week3,Week4 FROM x

    So it is just a standard resultset from sql server. I know Oracle is that different in that
    you create output array variables but the SELECT above is standard in SQL Server

    I basically want to do what your Query fixture does but call a stored proc instead with some input parms
    so that I can test it’s logic

    Denis

  31. Denison 19 Nov 2007 at 1:30 am

    I forget to mention that when I was looking at fitnesse by itself earlier I had hoped there were great
    new fixtures that would let me check my db code easily and insert test data beforehand.
    I think the dbfit insert fixture is great. It looks like it inserts test data
    and does an automatic rollback afterwards. Query is good too but I really want to
    test stored procs that I create/manage.

  32. gojkoon 19 Nov 2007 at 1:57 am

    Denis,

    I can modify the execute procedure fixture to have an implicit output argument for this result set, then you would be able to use it with the query. it would be something like this:

    |Execute procedure|myproc1|
    |param a|param b|$output1|
    |input1|input2|>>myvar|

    |Query|<<myvar|
    |f1|f2|

    I don’t have access to a SQL server for testing, so if you can do that for me, I’ll be happy to modify the code and get this done for you.

  33. Denison 19 Nov 2007 at 6:59 am

    Hi I just tried something like the following and it worked!
    |Query|exec myproc1 parm1,parm2,parm3|
    |col1|col2|col3|
    |data|data|data|
    |more Data|more..|more..|

    Thank you! You already had the correct fixtures and I didn’t know it.
    I also inserted test data using your insert fixture!
    |Insert|dbo.tablex|
    |colx|coly|colz|
    |test1|test2|test3|
    |test4|test5|test6|

    It puts test data in table(s) and when the dbfit test is finished it rolls back!!
    Excellent! I can test without worrying about affecting others or getting affected by them.

    dbfit truly is a great addition to fitnesse!!
    Sorry to have wasted your time!
    P.S. working at 2am!?? I hope you usually have work-life balance! :)

  34. Marisaon 19 Nov 2007 at 3:44 pm

    Hi Gojko,

    Thanks for the help with my previous problem. I’ve gotten the latest FIT for .NET binaries and was able to run a FIT test for a function in our database. However, I’m having a problem trying to test a stored procedure. I’m getting this error in the Execute Procedure cell:

    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
    at System.ThrowHelper.ThrowKeyNotFoundException()
    at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
    at dbfit.fixture.ExecuteProcedure.InitParameters(Parse headerCells)
    at dbfit.fixture.ExecuteProcedure.DoRows(Parse rows)
    at fit.Fixture.DoTable(Parse table)
    at fitlibrary.FlowFixtureBase.ProcessRestOfTable(Fixture theFixture, Parse theRestOfTheRows)

    I’ve tried referencing the stored procedure name in the following ways but still get the error above:

    DBName.dbo.procName
    DBName.procName
    dbo.procName
    procName

    The only thing I can come up with is that there could be some kind of permissions issue with respect to the user account I’m using to connect to the DB…but then I’m not sure why the function test would have executed (same connection string). THANK YOU for your help!

  35. gojkoon 19 Nov 2007 at 4:30 pm

    Hi Marisa,

    the error message typically means that the procedure or one of specified parameters cannot be found. if you are certain that the proc name is correct, check the parameter list for misspellings. I’m working on better error reporting, that should be included in the next version. if it still does not work, I can give you a partial build with better error report to tell you what’s wrong.

  36. Marisaon 19 Nov 2007 at 5:05 pm

    Hi Gojko,

    I will wait until the next version is available – I’ve tried to isolate whether a specific input or output parameter name is causing the problem but I seem to get the error regardless.

    Looking forward to the next version…which I hope will include support for guids as well? :-)

    Thanks.

  37. Michael McMahonon 21 Nov 2007 at 12:16 am

    I have used FitNesse for .net applications and have just downloaded the DBFit package. I have not been successful at connecting to our database. We are using SQL Server 2005. We usually have our databases secured using Windows Authentication, but set up a test database that did not use it. However, I keep getting the error:

    Standard Error:

    java.lang.NoClassDefFoundError: fit/FitServer
    Exception in thread “main”
    ——————————————————————————–
    Internal Exception:

    java.lang.Exception: FitClient: external process terminated before a connection could be established.
    fitnesse.components.CommandRunningFitClient$
    EarlyTerminationRunnable.run(CommandRunningFitClient.java:149)
    java.lang.Thread.run(Unknown Source)

    Unfortunately, I can’t give out the information I am using to connect to the database, which may make it difficult or impossible to assist me with this problem.

    first line is:
    !|dbfit.SqlServerTest|

    the next line is:
    |Connect|host machine|username|password|table name|

    Any advice??

    thanks,
    Michael

  38. gojkoon 21 Nov 2007 at 1:09 am

    Hi Michael,

    the error report suggests a couple of setup issues.

    It seems that you are running the java version of Fit test runner. (java.lang.NoClassDefFoundError: fit/FitServer). For SQL Server, you need to execute the .net version of the runner. If you have downloaded the “-complete” package, then everything is there and you just need to put these lines into the page header:

    !define COMMAND_PATTERN {%m %p}
    !define TEST_RUNNER {dotnet2\FitServer.exe}
    !define PATH_SEPARATOR {;}
    !path dotnet2\*.dll

    You can put that into the main suite page, or a suite set up, to make it available for all your tests.

    If you have downloaded just the dbfit binaries, you will need the .net version and you will also need the fit.net distribution. Then adjust those setup lines according to the location of those packages relative to your main fitnesse folder.

  39. Marisaon 26 Nov 2007 at 9:46 pm

    Hi Gojko,

    Thanks for the updated version today! It looks like the problem I’m having with that one proc has to do with the parameters, so I’ll look into that a little more.

    I was curious – do you have plans to add support for guids? Unfortunately this is preventing me from successfully implementing most of what I want to with DBFit because our DB is heavy in guids…

    Thanks again!

  40. gojkoon 26 Nov 2007 at 9:55 pm

    Hi Marisa,

    Generally I add support for stuff when people ask for it – so I can add GUIDs if that is important for you. Please send me a test case (fitnesse tables and db code if required) and i’ll make it work.

  41. Johanneson 27 Nov 2007 at 5:07 pm

    I’m refering to Marisa’s problem above with the wrong fitnesse version. I double checked, so probably I’m overlooking something, but it seems to me that dbFit (9.2) is NOT using the most recent fitnessedotnet version (1.3). I come to this conclusion by looking at the code base in SVN.
    Here’s the extract of dbfit.AbstractDataTableFixture (trunk):
    private bool IsMatch(Parse row, DataRow d)
    {

    foreach (DataColumnAccessor accessor in accessors)
    {
    ICellHandler cellHandler = CellOperation.GetHandler(cell, accessor);
    … }
    return true;
    }

    And here’s the SVN extract from fit.CellOperation (tags/20070615)
    public static ICellHandler GetHandler(Fixture theFixture, Parse cell, Accessor accessor)
    {
    return GetHandler(theFixture, cell, accessor.TypeAdapter.type);
    }

    So it seems to me that dbFit is not using the latest version but some older one.

  42. gojkoon 27 Nov 2007 at 10:29 pm

    Hi Johannes,

    You are completely right – sorry for not spotting that earlier and great catch. I’ve updated the source and re-compiled everything to work with Fitnesse.Net 1.3. See the download pages on Sourceforge and get dbfit-dotnet-binaries-20071127-fdn13.zip and dbfit-dotnet-binaries-and-deps-20071126-fdn13.zip.

  43. Marisaon 27 Nov 2007 at 11:37 pm

    Gojko,

    You ROCK!

    This is just a simplified example that is similar to something I’m trying to work with in DBFit.
    ———–
    Assumptions
    Table Name: Addresses
    Two Columns: AddressID (uniqueidentifier – primary key), Address (nvarchar 255)
    One Row: AddressID=Empty Guid, Address=123 Test Lane
    Procedure Name: proc_Addresses_Retrieve expects one parameter @AddressID – code as follows

    SELECT Address
    FROM Addresses
    WHERE AddressID = @AddressID
    ———–
    FitNesse Table
    !|dbfit.SQLServerTest|
    |Connect|My connection string here…|

    !|Execute Procedure|proc_Addresses_Retrieve|
    |AddressID|Address?|
    |00000000-0000-0000-0000-000000000000|123 Test Lane|
    ———–
    I would also like to be able to execute the INSERT and UPDATE procs via DBFit — if you want more example proc code and FitNesse tables for those just let me know.

    I can’t say “thank you” enough — once I’m able to work with our procs that depend on guids (which is about 98% of the procs), our test development will be so much faster (it will significantly decrease the fixture code the developers are writing right now).

  44. gojkoon 28 Nov 2007 at 12:32 am

    Marisa, thanks for the praise and all your support. all fixture types use the same sql type base, so when the guid support is added, everything will start working straight away. I’m not really good with sql server stuff, please send me both the create table and create procedure scripts for what you want and I’ll add the support.

  45. Johanneson 28 Nov 2007 at 10:47 am

    Addind to what Marisa says above, we have a similar problem using SQLServerTest. Consider the following to tables:

    !|Execute|!-
    CREATE PROCEDURE TEST_PROC
    AS
    SELECT * FROM MITARBEITER
    RETURN
    -!|

    !|Execute|!-
    CREATE PROCEDURE GetMitarbeiter ( @name varchar(10) )
    AS
    SELECT * FROM MITARBEITER WHERE NAME = @name
    RETURN
    -!|

    Whereas the first one works fine, the second one produces an exception:

    System.Data.SqlClient.SqlException: Wrong Syntax next to ‘PROCEDURE’ keyword.
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
    at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
    at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
    at dbfit.fixture.Execute.DoRows(Parse rows) in D:\work\dbfit\impl\dotnet\src\fixture\Execute.cs:line 29
    at fit.Fixture.DoTable(Parse table)
    at fitlibrary.FlowFixtureBase.ProcessRestOfTable(Fixture theFixture, Parse theRestOfTheRows)

    Seems to be a problem with SQL Server’s parameter handling?

  46. gojkoon 28 Nov 2007 at 11:27 am

    Johannes,

    Because DbFit tries to use fitnesse symbols as bound variables for “Execute”, it will actually try to map @name from the “create procedure” to a bound variable called name. That is why sql server throws an error, I guess. I don’t think that creating procedures on the fly is the best usage of a test tool anyway. From my experience, if you need some procedures for test-harness, that is best kept with the rest of database code, possibly in a separate schema.

  47. Johanneson 28 Nov 2007 at 2:32 pm

    Gojko,
    What we are trying to do is to create some kind of “mock stored procedures”, i.e. sprocs that are called by our sproc under test. Those can be different for every test case. Hm, maybe we need something like a “create mock procedure”-fixture which allows to “override” a certain sproc and restores it afterwards. Take this as a feature request :-)

  48. Jayon 28 Nov 2007 at 11:51 pm

    When are the tests rollbacked?

    At the end of each fitnesse test page, or at the end of a test suite, or..?

  49. gojkoon 28 Nov 2007 at 11:53 pm

    Hi Jay,

    if you use a DatabaseTest instance (i.e. test starts with dbfit.OracleTest/SqlServerTest/MySqlTest), then the transaction is automatically rolled back on the end of the page. You can commit if you want using the Commit table. If you use standalone fixtures or DatabaseEnvironment to connect, then you must roll back/commit manually.

  50. Johanneson 29 Nov 2007 at 12:08 pm

    I’m currently trying to extend DbFit by a few project specific fixtures. One of the things that IMO somewhat lowers the library’s extensibility is the visibility of DatabaseTest.environment. Changing it to “protected” would make the explicit use of DatabaseEnvironment fixture unnecessary since I could subclass from SqlServerTest and pass the environment to my home-made fixtures.

  51. gojkoon 29 Nov 2007 at 3:09 pm

    Johaness, Marissa

    I’ve added the support for GUIDs and changed DatabaseTest.environment to protected field. Please get dbfit-dotnet-20071130.zip from the dist folder and test. If you are happy with it, it will become part of the next regular release. Btw, to use guid support, load the guid handler in test setup:

    !|CellHandlerLoader|
    |Load|dbfit.util.GuidHandler|

  52. Marisaon 30 Nov 2007 at 4:16 pm

    Gojko,

    The add-in is working perfectly for me so far. It’s such a huge help for us – thank you!

  53. Marisaon 02 Dec 2007 at 2:34 am

    Gojko,

    Well, it’s me again. I’ve read through this page and the DatabaseTextFixture page, as well as your easy-to-read PDF. I couldn’t find reference to something I’m wanting to automate using DBFit – and that is comparing two result sets.

    For example, we have a stored procedure that returns two columns of data as follows:

    |OrganizationName|OrganizationState|
    |Acme Products|California|
    |etc.|etc.|

    Well, I’d like to be able to write a query manually via DBFit, store the results of the query in a variable on the page, and compare the contents of the stored variable to the results returned by the proc. So basically comparing one table of records to another.

    Example

    !|Query|SELECT OrganizationName, OrganizationState FROM Organization WHERE (my clauses…)|
    |>>myStoredResults|

    !|Execute Procedure|RetrieveOrganizationsStates param1 param2|
    |<<myStoredResults|

    I saw your instructions for creating a data regression test, but because many teams use the same central test database, I’d need to be able to re-generate the data with each test pass.

    If there’s something I’ve missed in your documentation that explains how to do this, or if you can think of a way to do this using the commands you’ve already provided in DBFit, I’d appreciate your help. Thanks very much.

  54. gojkoon 02 Dec 2007 at 2:42 am

    Hi Marisa,

    there is no fixture to compare two queries stored into variables. I’ll add that to the list of features for the next release.

  55. Peteon 03 Dec 2007 at 12:02 pm

    Hi,

    I’m new to fitnesse and dbfit and am trying to do an update on a table in our Oracle database using the below:-

    !|Update|QUOTE_VALUE|
    |Product_NAME|DATE|QUOTE_TYPE|QUOTE_SET_NAME|BID=|ASK=|
    |reference product|date_entered|Future|QS_EOD|price1|price2|

    My understanding is that with the above, i should be able to reference the product and enter the BID and ASK price into the table. I’m not sure if i’m executing the above correctly as i’m getting the following error:-

    Load data into Bid/Ask

    Update
    ——————————————————————————–
    Missing method: public TypeOfResult update(Type1 arg1) { } in class dbfit.OracleTest QUOTE_VALUE
    QUOTE_NAME
    ——————————————————————————–
    Missing method: public TypeOfResult qUOTE_NAME(Type1 arg1, Type2 arg2, Type3 arg3, Type4 arg4, Type5 arg5) { } in class dbfit.OracleTest QUOTE_DATE BID= ASK= QUOTE_TYPE QUOTE_SET_NAME
    Future.AUD.SFE.THREE MONTH AUD IR FUT FO.DEC.07

    Could someone help me please?

    Cheers,

    Peter

  56. gojkoon 03 Dec 2007 at 12:03 pm

    Hi peter,

    the error below would suggest that you are either using an older version of DbFit (update was introduced in 0.91), or that the page does not start with a DbFit test table.

    Can you please send me the whole test page source. Also, are you using the .NET or Java type of DbFit, which database (and version) are you connecting to, and can you verify that you are using the latest version of DbFit?

  57. Sachinon 04 Dec 2007 at 8:37 am

    Hi,Can i use DBfit to execute Join SQL Statements? For Example, select threedresponse as threedresponse from payrecs p, accounts a where p.accountid = id and a.username = ‘xxxxx’?
    At the moment, its giving java.sql.SQLException: ORA-00918: column ambiguously defined error.
    my script looks like this

    |Query| select threedresponse as threedresponse from payrecs p, accounts a where p.accountid = id and a.username = ‘xxxxx’|
    |THREEDRESPONSE|
    |4100|

  58. Johanneson 04 Dec 2007 at 11:42 am

    Gojko,

    Making DatabaseTest.environment protected works for us. There are more things, though, that seem to get into the way of extending (and reusing) the framework. For example, DbParameterAccessor hides its properties “Position” and “DbParameter” which we would like to access for generating certain kinds of sql commands.

    The general question hidden here is: Do you want to open DbFit for extension or keep it closed to make maintenance easier? If opening is your future strategy than it would probably make sense in the long run to differentiate between a public and an internal namespace to show extenders on what they can rely and what is implementation detail.

    As for now I’d be very happy with “DbParameterAccessor.Position” and “DbParameterAccessor.DbParameter” being public. :-)

  59. gojkoon 04 Dec 2007 at 12:41 pm

    Sachin,

    DbFit does no special SQL statement processing, it sends whatever you specify to the database. I can only guess that you have “id” in both tables (accounts and payrecs), so that in

    p.accountid=id

    oracle does not know which ID you are talking about. try to execute that same query in sqlplus or toad… if that does not help, please send me the create table statements for both those tables and I’ll try it out.

  60. gojkoon 04 Dec 2007 at 12:49 pm

    Hi Johannes,

    In general, I’m very open for it to be extended, and I’ll review the namespaces for everything for the next release.

    DbParameterAccessor was intentionally locked down to prevent mistakes, not to make maintenance easier. You can use the constructor:

    public DbParameterAccessor(DbParameter dbp, Type dotNetType, int position)

    to clone the parameter then fill in your details further on.

    I’m not really sure how you are going to use the extended version of the parameter accessor, as all standard fixtures will keep using the standard version. Can you send me more info on what you are trying to achieve and we’ll work something out.

  61. Stevaon 05 Dec 2007 at 8:25 am

    Hi Gojko,

    Two questions…

    1. Can you extend dbFit to support Oracle collection types?

    I’ve got a procedure that has a collection type (table) as a parameter:

    CREATE OR REPLACE
    TYPE “example”.”ex_ID_TABLE” IS
    TABLE OF ex_id

    PROCEDURE example_proc(arg1 IN tab1.id%TYPE, arg2 IN NUMBER := 0, arg3 IN NUMBER := 0, arg1 ex_id_table := ex_id_table())

    I’ve got this error when trying to test:

    |Execute Procedure|example_proc|
    |arg1|
    |<<da_id|

    System.NotSupportedException: Type TABLE is not supported
    at dbfit.OracleEnvironment.GetDBType(String dataType) in D:\work\dbfit\impl\dotnet\src\environment\OracleEnvironment.cs:line 149
    at dbfit.OracleEnvironment.ReadIntoParams(String[] queryParameters, String query) in D:\work\dbfit\impl\dotnet\src\environment\OracleEnvironment.cs:line 115
    at dbfit.OracleEnvironment.GetAllProcedureParameters(String procName) in D:\work\dbfit\impl\dotnet\src\environment\OracleEnvironment.cs:line 67
    at dbfit.fixture.ExecuteProcedure.InitParameters(Parse headerCells) in D:\work\dbfit\impl\dotnet\src\fixture\ExecuteProcedure.cs:line 116
    at dbfit.fixture.ExecuteProcedure.DoRows(Parse rows) in D:\work\dbfit\impl\dotnet\src\fixture\ExecuteProcedure.cs:line 43
    at fit.Fixture.DoTable(Parse table)
    at fitlibrary.FlowFixtureBase.ProcessRestOfTable(Fixture theFixture, Parse theRestOfTheRows)

    2. I’ve tried to get around this by wrapping this in another proc, since that parameter is optional:

    CREATE OR REPLACE procedure ex.ex_wrapper(arg1 in number) is
    begin
    example_proc(arg1);
    EXCEPTION WHEN NO_DATA_FOUND THEN NULL ; END ex_wrapper;
    /

    but no cigar:

    System.ApplicationException: Cannot read list of parameters for ex_wrapper – check spelling and access privileges
    at dbfit.OracleEnvironment.GetAllProcedureParameters(String procName) in D:\work\dbfit\impl\dotnet\src\environment\OracleEnvironment.cs:line 68
    at dbfit.fixture.ExecuteProcedure.InitParameters(Parse headerCells) in D:\work\dbfit\impl\dotnet\src\fixture\ExecuteProcedure.cs:line 116
    at dbfit.fixture.ExecuteProcedure.DoRows(Parse rows) in D:\work\dbfit\impl\dotnet\src\fixture\ExecuteProcedure.cs:line 43
    at fit.Fixture.DoTable(Parse table)
    at fitlibrary.FlowFixtureBase.ProcessRestOfTable(Fixture theFixture, Parse theRestOfTheRows)

    Where dbFit gets the Oracle procedure parameters from – is it some Oracle system view which may be somehow restricted for viewing? The proc and wrapper work in Toad, no spelling errors, I’m using the same user to connect in dbFit and in Toad… I get the same error when I put a name that doesn’t exist, so I believe it just can’t see the wrapper I added for some reason. I’ve tried creating public synonims but it doesn’t work.

    There is a happy end – finally I managed to get around it by doing this

    |Execute|begin example_proc(!-:da_id-!); end;|

    (the proc stores the result in temporary table so I can run the query on it afterwards to check the results)

    And a final comment – it would be truly great if you can store the query in variable (comment 54 above), connect to two instances and compare. That would come really handy for some data migration testing we’re doing at the moment. It is tedious to create the rows manually in Fitnesse and for different migration runs the data can change significantly, so we’d have to recreate/update the expected test results which is a royal pain.

    Thanks for the great tool.

    Cheers,
    Steve

  62. gojkoon 05 Dec 2007 at 9:17 am

    Hi Steve,

    1 – Oracle collection types are on my list. A few people already asked for that, but it turned out to be much trickier to implement and will have to wait for a major restructuring of DbFit. Until that happens, I suggest sending a CSV list to a stored proc and unpacking it there.

    2 – “Cannot read list of parameters for ex_wrapper” – is dbfit connecting as user “ex” or some other user. If as a different user, then prefix the procedure name with the schema name (i.e. |Execute procedure|ex.ex_wrapper|). If this does not help, please send me your whole test page.

    DbFit reads stored procedure metadata from all_arguments view (you can see the .net version of that code on sourceforge, see lines 41-65.

    3 – storing results into a query variable will be done for the next release.

    thanks for the support!

  63. Marisaon 06 Dec 2007 at 6:37 pm

    Hello,

    I’m not sure why, but I’ve got a Query command that is behaving like an Ordered Query command. Here’s the example:

    !|Query|EXEC proc_MyRetrieveProc 123, xyz|
    |Col1?|Col2?|Col3?|
    ||1|aaaaa|
    ||2|bbbbb|

    I’m actually getting a failing result because the results are coming back as:

    |Col1?|Col2?|Col3?|
    ||2|bbbbb|
    ||1|aaaaa|

    Since I’m not using the Ordered Query command I thought order wouldn’t matter? Am I missing another directive?

    Thanks for your help!

  64. gojkoon 06 Dec 2007 at 7:26 pm

    Marisa,

    all your columns are non-key (all have ? in the name), so DbFit does not consider any of them when matching. I suggest you remove ? from all column names (or if any of those is the primary key, remove ? for that column).

  65. gojkoon 06 Dec 2007 at 9:21 pm

    If you are using DbFit and you are happy with it, I need some information from you for the new DbFit web site. Please look at are-you-using-dbfit? to see how you can participate.

  66. Marisaon 06 Dec 2007 at 9:45 pm

    Hi Gojko,

    Removing the ? from the columns I wanted to use as matching columns worked – thank you!

    I will work on my comment for your new site and get it to you early next week.

  67. Marisaon 10 Dec 2007 at 4:28 am

    Hi Gojko,

    I’m getting the “Object reference not set to the instance of an object” error in a particular case. Here’s a simplified version of a query I’m running:

    !|Query|SELECT * FROM Addresses WHERE AddressID = @testAddressID|
    |AddressID|Line1?|Line2?|UpdatedBy?|IsValid?|

    In the above, AddressID and UpdatedBy are both guids. Line1 and Line2 are nvarchar, and IsValid is a nullable bit.

    When the following data is returned, I do NOT get the exception:

    |AddressID |Line1? |Line2? |UpdatedBy? |IsValid?|
    |(valid guid)|123 Test Lane|Test, CA 12345|(valid guid)|False|

    However, when the UpdatedBy field returns as null (which is valid for the case), I get the exception for the IsValid bit field.

    Here’s the exception message:
    System.NullReferenceException: Object reference not set to an instance of an object.
    at fitnesse.handlers.BoolHandler.HandleEvaluate(Fixture fixture, Parse cell, Accessor accessor)
    at fitnesse.handlers.AbstractCellHandler.HandleCheck(Fixture fixture, Parse cell, Accessor accessor)
    at dbfit.AbstractDataTableFixture.CheckMatchingRow(Parse row, DataRow d) in D:\work\dbfit\impl\dotnet\src\fixture\AbstractDataTableFixture.cs:line 82
    at dbfit.AbstractDataTableFixture.DoRows(Parse rows) in D:\work\dbfit\impl\dotnet\src\fixture\AbstractDataTableFixture.cs:line 52
    at fit.Fixture.DoTable(Parse table)
    at fitlibrary.FlowFixtureBase.ProcessRestOfTable(Fixture theFixture, Parse theRestOfTheRows)

    I know that the older version of FIT for .NET (without your updates) has problems with nullable Boolean values…but I’m just stumped because I have your .NET updates, and am only getting the exception in a very specific case.

    As always, I appreciate your help.

  68. Kevinon 10 Dec 2007 at 3:47 pm

    Hello,

    I have a quick question regarding the downloads. what’s the difference between the regular binaries and the ones labeled with “fdn”? thanks!

  69. gojkoon 10 Dec 2007 at 3:54 pm

    Hi Kevin,

    DbFit was upgraded to use the latest version of FitNesse.NET (1.3) in 0.92 release, so binaries without -fdn-13 are linked with FitNesse .NET 1.2, and those with -fdn-13 are linked with FitNesse.NET 1.3. Upcoming releases will be based on the FitNesse.NET 1.3 branch, so if you are just starting with DbFit, get those with -fdn.

  70. gojkoon 10 Dec 2007 at 4:05 pm

    Marisa,

    i’m not sure how the null updatedby field can effect the next field in the table. what is in the cell for updatedby when you expect null? is it empty? If yes, please use the keyword null. Can you send me the create table statement and your test page so I can reproduce the problem here and fix it?

  71. andyon 11 Dec 2007 at 9:16 pm

    I’m looking at the 20071126 snap and I do not see any support for SQLServer in the Java sources. Do you have any idea when this will be available. Thanks.

  72. gojkoon 11 Dec 2007 at 9:31 pm

    HI Andy,

    I never had a request for that, everyone using SqlServer is doing so with the .NET version. If you need it in Java, I can port it fairly quickly.

  73. andyon 11 Dec 2007 at 9:50 pm

    Really. I was looking at AbstractDBEnvironment and subclassing my own for both SQLServer and Sybase. We have a few targets you see and countless stored procs with no tests. I need to modify a couple and need decent test bed in place before I venture forth with the new requirements.

  74. gojkoon 11 Dec 2007 at 10:07 pm

    Can you use the .NET version? the syntax is absolutely the same and it will give you sql server support out of the box (don’t know how much sybase is different, but if you are willing to help with testing, we can implement this relatively easily). If you have to use the java version because of integration testing, let me know which JDBC driver you are using for Sql Server so that I can implement and test the port using the same thing. Alternatively, if you don’t mind getting your hands a bit dirty, subclassing AbstractDBEnvironment is the way to go. See the .NET implementation for details.

  75. andyon 11 Dec 2007 at 10:58 pm

    I thought you might say that ;-) Sure, I will give it a whirl. .NET? I develop on a Mac/Unix most of the time. In my case I have more than one driver with which to test Sybase over and it seems that AbstractDBEnvironment subclasses are tied to a particular driver e.g. getDriverClassName(). I’ll probably end up passing some kind of Driver encapsulation to SybaseEnvironment. Just thought I’d pass that on.

  76. Marisaon 14 Dec 2007 at 7:22 pm

    Hi Gojko,

    Is the Inspect feature available in the current version of DBFit? I tried the following:

    !|dbfit.SQLServerTest|
    |Connect|MyConnectionString|

    !|Inspect|MyTableName|

    I got the error: fitlibrary.exception.InvalidMethodException:Missing method ‘inspect’ with 1 argument(s).

  77. gojkoon 14 Dec 2007 at 7:39 pm

    Yes, but you have to tell it what to inspect. Use this

    !|Inspect table|MyTableName|

    See this for further examples.

  78. Marisaon 14 Dec 2007 at 8:23 pm

    Doh! Just pulled the dbfit DLL into a project and saw that it’s “InspectProcedure” etc. Thanks!

  79. Kevinon 20 Dec 2007 at 10:32 pm

    Hi again Gojko,

    I was wondering, is it possible to store multiple rows of results in a single variable? what i want to do is compare the contents of two database tables which may have an arbitrary number of rows. Let me know your thoughts on this; thanks!

  80. Kevinon 21 Dec 2007 at 3:49 pm

    Also i’ve found a bug in how saving null values into variables works; if you save a null and try to compare it to a null in the future, it fails. This may be an issue in column fixture itself. here’s the tables to replicate it:

    !|dbfit.SqlServerTest|

    !|Connect|Server=${server};Database=${database};Trusted_Connection=yes;|

    !|Query|Select null as test|
    |test?|
    |>>nullcheck|

    !|Query|Select null as test|
    |test?|
    |<<nullcheck|

  81. gojkoon 22 Dec 2007 at 1:25 am

    Hi Kevin,

    I’m working on the feature to store a query result into a symbol and than use that for comparison. That will be released with 0.93 in the next week or so. Regarding null and comparisons, null comparison is typically managed by the NULL cell handler, so individual type comparison handlers often do not check for that. I may be able to develop a workaround for DbFit, because all DbFit processing goes through the DbParameterAccessor. Give me a day or two to try things out and i’ll get back to you.

  82. Bobbyon 26 Dec 2007 at 7:00 am

    Hiya,

    Did anyone get round to writing an environment for sybase? I am about to start but don’t want to go re-inventing the wheel.

    Thanks,

    Bobby

  83. gojkoon 26 Dec 2007 at 7:08 am

    Hi Bobby,

    there were a few queries about that, but nobody actually started to work on it as far as I know. let me know if you need any help with it.

  84. gojkoon 27 Dec 2007 at 5:38 am

    dbfit 0.93 is just released, with support for storing query results into variables and comparing them… see http://gojko.net/2007/12/27/dbfit-093-storing-and-comparing-queries for more information

  85. Kevinon 02 Jan 2008 at 7:57 pm

    Awesome, thanks for the new features!

    I have one issue though with the new query comparison feature; When i use it, i don’t see any results regardless of if they are equivalent queries or not. My question is two-fold:
    does the DatabaseTest Flow-fixture support this?
    and can we compare queries from different databases/servers (i.e. if i reconnect with a new connection string)? my example utilizes both scenarios and it doesn’t seem to work.

    Thanks for all the hard work!

  86. gojkoon 02 Jan 2008 at 9:00 pm

    Hi Kevin,

    When i use it, i don’t see any results regardless of if they are equivalent queries or not.

    You should see equivalent rows in green. Can you send me your test table and page?

    DatabaseTest Flow-fixture support this?

    Yes, using absolutely the same syntax as standalone. You should be able to reconnect to another database and use comparisons, because query results are detached and cached in memory. Again, please send me a test page and db code to double-check what your problem is…

  87. Kevinon 03 Jan 2008 at 4:33 pm

    Here’s a stripped down table that is giving me the same issue as what i had mentioned previously. I have tried it on a sql server 2000 and a 2005 database, neither of which work:

    !|dbfit.SqlServerTest|
    |Connect|Server=${server};Database=${database};Trusted_Connection=yes;|
    |Store Query|Select ‘blah’ as one, ‘blah2′ as two|first|
    |Store Query|Select ‘lala’ as one, ‘lolo’ as two|second|
    |compare stored queries|first|second|
    |one|two|

  88. Marisaon 03 Jan 2008 at 5:02 pm

    Hello Gojko,

    I am having to use the SQL CAST function to cast int values to nvarchar in order for certain verifications to pass. Here’s an example:

    |Set Parameter|expectedCountOfRecords|10|

    !|Query|SELECT COUNT(*) FROM Customers AS CountOfCustomers WHERE CustomerState = ‘TN’|
    |CountOfCustomers?|
    |<<expectedCountOfRecords|

    Even if the COUNT query returns 10, the cell is still marked as failing/red. If I convert/cast the expectedCountOfRecords variable to nvarchar, the test will pass.

    Is there something inherently wrong with the way I’m setting values in variables, or is it that DBFit (or FitNesse) is converting all values to strings when running comparisons (in which case I guess I just need to continue casting to nvarchar)?

    Thanks for your help.

  89. gojkoon 03 Jan 2008 at 9:20 pm

    Hi Marisa,

    The problem is in strongly typed FitNesse plumbing. As ‘Set Parameter’ does not know which type the value is, it is made string by default. But the data coming out of the database in your example is a number, so the comparison fails. There is a good workaround in this case – use markup variables instead of symbols if you just want to parameterise tests and do not actually need the value in a bound variable. FitNesse parses markup variables in place of their usage, so it will be just as if you wrote 10 in the cell.

    !define expectedCountOfRecords {10}

    !|Query|SELECT COUNT(*) FROM Customers AS CountOfCustomers WHERE CustomerState = ‘TN’|
    |CountOfCustomers?|
    |${expectedCountOfRecords}|

  90. gojkoon 03 Jan 2008 at 9:23 pm

    Hi Kevin,

    ‘compare stored queries’ has to be a separate table, like query (it behaves as a row fixture). The test works ok if you use it in flow mode (just put a blank line between the last store query and compare stored queries

    !|dbfit.SqlServerTest|
    |Connect|Server=${server};Database=${database};Trusted_Connection=yes;|
    |Store Query|Select ‘blah’ as one, ‘blah2′ as two|first|
    |Store Query|Select ‘lala’ as one, ‘lolo’ as two|second|

    |compare stored queries|first|second|
    |one|two|

    if you cannot use flow mode (i.e. if dbfit.SqlServerTest is not the first table on the page) then you should use the database environment table to connect to the database. StoreQuery and CompareStoredFixtures are then available as fixtures in the dbfit.fixture namespace. Let me know if this does not help, i’ll write a complete test page for you to try.

  91. Kevinon 04 Jan 2008 at 10:11 pm

    thanks for the tip, i actually had to break the table out further:

    !|dbfit.SqlServerTest|
    |Connect|Server=${entserver};Database=${entdatabase};Trusted_Connection=yes;|
    |Store Query|Select ‘blah’ as one, ‘blah2′ as two|first|

    |Store Query|Select ‘lala’ as one, ‘lolo’ as two|second|

    |compare stored queries|second|first|
    |one|two|

    having two consecutive Store query statements doesnt work, as the second one seems to not get run (might be a bug). The strange thing about breaking the table up is that the normal query fixture works if it is part of the whole table:

    !|dbfit.SqlServerTest|
    |Connect|Server=${server};Database=${database};Trusted_Connection=yes;|
    |Query|select * from ${entTable}|
    |DashboardID|UserID|DashboardValue?|DashboardValue2?|
    |1|person1|$434,821|12.34|
    |14|person1|12|null|
    |19|person2|11/10/2005|null|
    |19|person3|11/10/2005|null|

    works fine for me.

    And yes, i cannot use true flow mode without combining all the statements into one table, since this is the last assertion i make in my tests after a lot of setup. I’ll try to use the database environment fixture, but I’m having trouble finding examples on how to use them. If you could point me towards examples on using database environment fixtures with other ones, or if you are willing to write up an example page for me I’d be grateful :)

    Thanks!

  92. gojkoon 06 Jan 2008 at 1:26 pm

    Hi Kevin,

    See http://www.fitnesse.info/dbfit:databaseenvironment for a more detailed explanation of DatabaseEnvironment and a simple example. Also, see http://www.fitnesse.info/dbfit:modes for a more detailed explanation of standalone and flow mode differences.

    If you download the dbfit-complete package, you’ll find a bunch of examples in DotNet.AcceptanceTests.OracleAcceptanceTests.StandaloneFixtures, DotNet.AcceptanceTests.SqlServerAcceptanceTests.StandaloneFixtures, NewJava.AcceptanceTests.OracleTests.StandaloneFixtures and NewJava.AcceptanceTests.MySqlTests.StandaloneFixtures namespaces.

  93. Mitjaon 07 Jan 2008 at 12:46 pm

    Hi Gojko
    Is it possible to check number of records in ref cursor. Similar functionality to QueryStats which would take a ref cursor for input.

    Thanks

  94. Kevinon 07 Jan 2008 at 4:08 pm

    Awesome, thanks i got it working!

    One quick note; i could not find a fixture class in the .net dlls named CompareStoredQueries, so i had to utilize the DatabaseTest flow-fixture for this. i’m not sure if this is intentional or if there’s supposed to be a comparestoredqueries fixture defined somewhere that i couldn’t find right away. My final tables look like this:

    !|dbfit.fixture.DatabaseEnvironment|sqlserver|
    |Connect|Server=${server};Database=${database};Trusted_Connection=yes;|
    !|dbfit.fixture.StoreQuery|select * from ${entTable}|first|
    !|dbfit.fixture.DatabaseEnvironment|sqlserver|
    |Connect|Server=${entserver};Database=${entdatabase};Trusted_Connection=yes;|
    !|dbfit.fixture.StoreQuery|select * from ${sourceTable}|second|
    !|dbfit|SqlServerTest|
    |CompareStoredQueries|first|second|
    |DashboardID|UserID|DashboardValue?|DashboardValue2?|

    thanks again for your help!

  95. gojkoon 07 Jan 2008 at 4:19 pm

    Hi Mitja,

    not yet, I’ll add that to the next version.

  96. gojkoon 07 Jan 2008 at 4:24 pm

    Hi Kevin,

    My bad – nice catch! Get the new version from

    http://dbfit.svn.sourceforge.net/svnroot/dbfit/dbfit/dist/dbfit-dotnet-20080107.zip

    I’ve changed the class to public, you should be able to use it directly now.

    Btw, no need to use |sqlserver| the second time, it will actually be better if you don’t. Use that only to connect to a different type of database. So here is what I suggest you use:

    !|import|
    |dbfit.fixture|

    !|Database Environment|sqlserver|
    |Connect|Server=${server};Database=${database};Trusted_Connection=yes;|

    !|Store Query|select * from ${entTable}|first|

    !|Database Environment|
    |Connect|Server=${entserver};Database=${entdatabase};Trusted_Connection=yes;|

    !|Store Query|select * from ${sourceTable}|second|

    !|Compare Stored Queries|first|second|
    |DashboardID|UserID|DashboardValue?|DashboardValue2?|

  97. Oscar Centenoon 07 Jan 2008 at 5:30 pm

    Hi.
    I’m analyzing dbfit por my development team but we still develop on SQL Server 2000.

    I have made tests with QUERY and EXECUTE and everything works fine. However, since SQL SERVER 2005 uses sys.columns, I cannot use INSERT in dbfit tables… Do you think you could make dbfit compatible with SQL Server 2000 for Inserts?

    This code works fine:
    !|Execute|Insert into MyTable values (‘123456789012345′,’012345678901234′|

    The next code doesn’t work. The error is “System.Data.SqlClient.SqlException: Invalid object name ’sys.columns’.

    !|Insert|MyTable|
    |Column1|Column2|
    |123456789012345|012345678901234|

    I think dbfit works awesome and its a gret idea and tool, thanks!

  98. gojkoon 07 Jan 2008 at 5:44 pm

    Hi Oscar,

    I’d be more than happy to make it work with Sql Server 2000, but I’ll need your help to do it. If you have a bit of time to spend testing and know how to extract meta-data from sql server 2000, let’s do it.

  99. gojkoon 07 Jan 2008 at 10:20 pm

    Initial support for SQL Server 2000 is done: see initial support for sqlserver 2000 in dbfit for more information.

  100. Reuben Grinbergon 14 Jan 2008 at 9:16 pm

    Hello,

    Is there any way to get a return value from a Stored Procedure on SQL Server 2005? I tried following the docs for return values from functions — using a question mark — but this doesn’t seem to work.

    For example:
    !|EXECUTE PROCEDURE|SomeStoredProc|
    |SomeInput|?|
    |Blah|1|

    However, the ‘?’ is hillighted red when I run this and I get the following exception:

    System.ApplicationException: Cannot find parameter
    at dbfit.fixture.ExecuteProcedure.InitParameters(Parse headerCells) in D:\work\dbfit\impl\dotnet\src\fixture\ExecuteProcedure.cs:line 128
    at dbfit.fixture.ExecuteProcedure.DoRows(Parse rows) in D:\work\dbfit\impl\dotnet\src\fixture\ExecuteProcedure.cs:line 43
    at fit.Fixture.DoTable(Parse table)
    at fitlibrary.FlowFixtureBase.ProcessRestOfTable(Fixture theFixture, Parse theRestOfTheRows)

    I tried working around this by doing
    |QUERY|!-
    DECLARE @RetVal BIT
    EXEC @HasAccess = SomeStoredProc ‘Blah’
    SELECT @RetVal as Ret
    !-|
    |Ret|
    |1|

    However, the !- -! syntax doesn’t seem to be working on SQL Server 2005.

    I tried this:
    !|QUERY|!-
    SELECT 1 as Val
    !-|
    |Val|
    |1|

    and got this exception:
    fitlibrary.exception.InvalidMethodException: Missing method ‘val’ with 0 argument(s).
    at fitlibrary.Method.FindFirst(Object[] theTargets, String theMethodName, Int32 theParameterCount)
    at fitlibrary.FlowFixtureBase.FindMethod(CellRange theCells)
    at fitlibrary.FlowFixtureBase.ProcessFlowRows(Parse theRows)

    BTW, DBFit is awesome. Thanks so much for working on it.

    Thanks,
    Reuben

  101. gojkoon 14 Jan 2008 at 9:42 pm

    Hi Reuben,
    the error suggests that your stored procedure has an output parameter and is not a stored function. ? by itself only works with a stored function. with a stored procedure, specify the output parameter name (i.e. myvalue?). If this does not answer your question, please send me the stored procedure to test.

  102. Reuben Grinbergon 14 Jan 2008 at 11:47 pm

    Stored procedures in SQL Server 2005 can return values without having an output parameter.

    For example:

    CREATE PROCEDURE dbo.ReturnOne
    (@Arg VARCHAR(100))
    AS
    BEGIN
    RETURN 1
    END

    Then we could use this stored procedure as:
    DECLARE @One INT
    EXEC @One = ReturnOne ‘blah’

    It would be great if I could get this returned parameter using the same syntax as a stored function (using ‘?’ to denote the return value:

    !|EXECUTE PROCEDURE|ReturnOne|
    |Arg|?|
    |Blah|1|

  103. gojkoon 15 Jan 2008 at 8:11 am

    Hi Reuben,

    In that case, I would suggest that you write a small wrapper function. There is no way to know that such a procedure will return any output and what the type of such output will be. In order to have it integrated with DbFit, I need to know the type of result in advance.

    There is one exception – if the procedure opens a cursor, then it can be handled with the “query” fixture. see StoredProcReturningQuery.

  104. Udo Froehlingon 15 Jan 2008 at 11:06 am

    Hello,
    first thank you for publishing dbfit, it improves our tests a lot. I on the way to use more features with our oracle db and get the following exception when i try to put the query result in a variable. The problem arises with a column which is defined as NUMBER(13)

    java.lang.NumberFormatException
    at java.math.BigDecimal.(BigDecimal.java:368)
    at java.math.BigDecimal.(BigDecimal.java:647)
    at dbfit.util.BigDecimalParseDelegate.parse(BigDecimalParseDelegate.java:6)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at fit.TypeAdapter$DelegateClassAdapter.parse(TypeAdapter.java:394)
    at dbfit.util.DbTypeAdapter.parse(DbTypeAdapter.java:46)
    at dbfit.fixture.RowSetFixture.findMatchingRow(RowSetFixture.java:102)
    at dbfit.fixture.RowSetFixture.doRow(RowSetFixture.java:86)
    at fit.Fixture.doRows(Fixture.java:165)
    at fit.ColumnFixture.doRows(ColumnFixture.java:20)
    at dbfit.fixture.RowSetFixture.doRows(RowSetFixture.java:73)
    at fit.Fixture.doTable(Fixture.java:157)
    at fitlibrary.FlowFixture.interpretTableWithFixture(FlowFixture.java:89)
    at fitlibrary.FlowFixture.runRow(FlowFixture.java:123)
    at fitlibrary.FlowFixture.doTable(FlowFixture.java:99)
    at fitlibrary.FlowFixture.doTable(FlowFixture.java:92)
    at fitlibrary.FlowFixture.interpretTableWithFixture(FlowFixture.java:89)
    at fitlibrary.FlowFixture.interpretTable(FlowFixture.java:62)
    at fitlibrary.FlowFixture.interpretTables(FlowFixture.java:46)
    at fitlibrary.FlowFixture.interpretTables(FlowFixture.java:27)
    at fit.Fixture.doTables(Fixture.java:73)
    at fit.FitServer.process(FitServer.java:74)
    at fit.FitServer.run(FitServer.java:50)
    at fit.FitServer.main(FitServer.java:41)

  105. Marisaon 17 Jan 2008 at 10:30 pm

    Hi Gojko,

    I just implemented the compare stored queries feature for a procedure that returns about 50 columns and hundreds to thousands of records…this feature is awesome! It only took me about half an hour to do – and that was just because I had to write the complicated query that returns the expected results. Thank you!

  106. Marisaon 21 Jan 2008 at 6:20 am

    Hi Gojko,

    I am trying to use the DBFit DatabaseTest fixture on a SetUp page for a Selenium WebTest page.

    eg

    TryWebTest — a Test page that implements the Selenium WebTest fixture you have here on your site.
    TryWebTest.SetUp — a page that implements SQLServerTest from DBFit — I’m using it to set up data so that I can bring up a web page with certain data via the TryWebTest page.

    When the test runner tries to execute the first WebTest command, I receive the following error:

    fitlibrary.exception.InvalidMethodException: Missing method ’startbrowser’ with 7 argument(s).

    I believe this is because DBFit’s DatabaseTest is the first fixture instantiated and it is a flow-style, so when I try to use the WebTest fixture, the WebTest fixture is not recognized.

    What would be the best way to organize these pages so that I can use DBFit to create test data and then run the WebTest fixture such that it utilizes values from symbols assigned on the DBFit set-up page?

    Thanks for your help…and I hope that made sense.

  107. gojkoon 21 Jan 2008 at 10:02 am

    Hi Marisa,

    You can use DbFit in standalone mode. Then webtest fixture should control the page in flow mode, and dbfit fixtures will be used as standalone. See http://fitnesse.info/dbfit:modes and http://fitnesse.info/dbfit:databaseenvironment

  108. Vineet Reynoldson 24 Jan 2008 at 2:13 pm

    Hi Gojko,
    I’m attempting to use DBFit to test against Oracle stored procedures that have IN/OUT parameters, not plain IN or OUT params. A sample stored procedure I test against is as follows:

    create or replace
    procedure sut_procedure
    ( param in out varchar2
    ) as
    begin
    if param = ”
    then
    param:=’XX’;
    end if;
    end sut_procedure;

    The test tables that I’ve used, are:

    1>

    !|dbfit.OracleTest|
    !|connect|10.80.150.187:1521|fcjitr2|fcjitr2|fcjdev|

    !|execute procedure|sut_procedure|
    |param?|
    |XYZ|XYZ|

    2>

    !|dbfit.OracleTest|
    !|connect|10.80.150.187:1521|fcjitr2|fcjitr2|fcjdev|

    !|execute procedure|sut_procedure|
    |param|param?|
    |XYZ|XYZ|

    3>

    !|dbfit.OracleTest|
    !|connect|10.80.150.187:1521|fcjitr2|fcjitr2|fcjdev|

    !|execute procedure|sut_procedure|
    |param?|param|
    |XYZ|XYZ|

    Both of them, when executed, throw java.sql.SQLException. The stack trace is as follows:

    java.sql.SQLException: Missing IN or OUT parameter at index:: 1
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1681)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3280)
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3390)
    at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4223)
    at dbfit.fixture.ExecuteProcedure.runRow(ExecuteProcedure.java:208)
    at dbfit.fixture.ExecuteProcedure.executeStatementForEachRow(ExecuteProcedure.java:158)
    at dbfit.fixture.ExecuteProcedure.doRows(ExecuteProcedure.java:117)
    at fit.Fixture.doTable(Fixture.java:157)
    at dbfit.fixture.ExecuteProcedure.doTable(ExecuteProcedure.java:96)
    at fitlibrary.FlowFixture.interpretTableWithFixture(FlowFixture.java:89)
    at fitlibrary.FlowFixture.interpretTable(FlowFixture.java:62)
    at fitlibrary.FlowFixture.interpretTables(FlowFixture.java:46)
    at fitlibrary.FlowFixture.interpretTables(FlowFixture.java:27)
    at fit.Fixture.doTables(Fixture.java:73)
    at fit.FitServer.process(FitServer.java:74)
    at fit.FitServer.run(FitServer.java:50)
    at fit.FitServer.main(FitServer.java:41)

    Any ideas on how to go ahead resolving this ? I presume that there would some changes made to the source code. Btw, the Callable Statement is prepared using the following string { call sut_procedure(?)} in the first case, and { call sut_procedure(?,?)} in the latter two.

    On a related note, I’ve noticed that a minor fix needs to be made in GetParameterDirection() of dbfit.environment.OracleEnvironment class. Parameters that are both IN and OUT, are represented using IN/OUT and not ‘IN OUT’. You may want to include this change. Sorry, couldnt get a diff file out to help you :P

    Thanks for all the help, offered here!!

  109. Marisaon 24 Jan 2008 at 8:14 pm

    Hi Gojko,

    Thank you – I am in the process of updating our tests to use standalone mode where required.

    I read the databaseenvironment documentation and saw that there is a way to exit standalone mode – is there a way to exit flow mode? Here’s what I’m wanting to do:

    1) Initialize the WebTest fixture
    2) Connect via flow mode so that I can
    3) Use SetParameter and ClearParameters (I use a lot of included pages that implement symbols, so I need to initialize those all to null in each suite’s SetUp) – from what I can tell by trying to use SetParameter and ClearParameters, and by looking at the source code, it looks like these are only available in DatabaseTest (flow mode)?
    4) Exit flow mode if possible, then Connect via standalone mode so that I can set-up test data
    5) Use the WebTest fixture

    I hope that makes sense – I appreciate any guidance you can provide.

  110. Marisaon 25 Jan 2008 at 12:47 am

    Hi Gojko,

    Sorry – my last post was not very clear. I can successfully use standalone mode on WebTest pages, so that’s great. The core issue is that I cannot use SetParameter or ClearParameters. From looking at the source, it looks like those are only available in flow-mode. If I had more development experience, I would try to figure out how to add those commands to standalone mode…

    So at this point is it just not possible to use SetParameter and ClearParameters in standalone mode?

    THANK YOU for your help!

  111. Marisaon 25 Jan 2008 at 8:49 am

    Geez…sorry…don’t know why I didn’t think of this before. I just added a method to WebTest that calls fit.Fixture.ClearSaved – that’s all I needed. Thanks.

  112. gojkoon 27 Jan 2008 at 7:41 pm

    Hi Vineet,

    IN OUT parameters are not yet supported, I still cannot think of a good enough syntax for that. That is one of the things that is on the top of my list. A workaround is to create a simple wrapper procedure that splits that IN OUT into one IN and one OUT argument.

  113. Vineet Reynoldson 27 Jan 2008 at 9:54 pm

    Hi Gojko,
    I was about to mail you. Thought my comment was treated as spam, for a moment. One of the methods, that I had thought of, to achieve IN OUT parameters, was to create 2 separate columns in the test table, one for the IN param, the other for the OUT param (the name of this column will be the same as the column for IN, but with a trailing ?).
    Of course, this results in a different CallableStatement being prepared, than the one we expect to create. And if I’m not wrong, the support for IN OUT parameters, might have to create the appropriate CallableStatement. Havent got to work on this idea yet, but I’ll let you know how this comes across. Will send you the patch, if this comes through. Thanks once again.
    Regards,
    Vineet

  114. gojkoon 27 Jan 2008 at 10:11 pm

    Hi Vineet,

    I was away for a few days, that is why I did not reply earlier. I thought about using that syntax already, but that would require changing the underlying structure quite a bit, because one DB parameter will be mapped to more than one cell. However, from the point of usage, that seems the simplest, so it would be a logical thing to do.

    Does anyone else have any thoughts on this?

  115. Kevinon 30 Jan 2008 at 8:54 pm

    Hello again gojko,

    I have another request for comparing stored queries against each other. what i’m doing is comparing results from INFORMATION_SCHEMA.COLUMNS in sql server between a static table and a generated table. The table that gets generated has a few extra columns added to it by design, and i’d like to make sure that the columns in the static table are in the generated table as well. however i cannot use the compare stored queries functionality because of the extra columns that are in the generated table. I would normally remedy this by using subqueries but the two tables i’m comparing now are on different databases and different servers. So my request is this:

    Would it be possible to add a facility to compare stored queries with the assumption that one query is supposed to return a subset of the other query?
    Let me know what you think. Thanks so much!

  116. gojkoon 30 Jan 2008 at 10:45 pm

    Hi Kevin,
    compare queries should work only on the columns that you listed in the fitnesse table. just don’t specify the columns that are not in the other table. does this solve your problem (or have I misunderstood something?)

  117. Kevinon 30 Jan 2008 at 11:16 pm

    Thats not exactly what i meant, yeah. i query the INFORMATION_SCHEMA.COLUMNS view of the DB in sqlserver and that returns a bunch of rows with descriptions of the columns in the table i want. thats why i’m getting this issue, since the query about the columns for the generated table returns more rows than the static table.

    However this isn’t so important anymore, because i just hardcoded a filter into the query to ignore the extra columns in the generated table.

  118. gojkoon 04 Feb 2008 at 2:51 am

    Experimental support for IN/OUT parameters is now available. Please help test it by verifying that your current tests work.
    See http://gojko.net/2008/02/04/dbfit-experimental-support-for-inout-parameters/ for more information

  119. Kevinon 04 Feb 2008 at 7:32 pm

    Hi Gojko,

    I’m curious if you plan on implementing support for SyBase at some point? My company does some sybase work and it would be nice to be able to leverage dbfit against that. It’s not a huge priority though, since i would imagine extending support to a brand new database server would likely be difficult i’d imagine but it definitely would be nice to have :) .

  120. gojkoon 05 Feb 2008 at 12:12 am

    Hi Kevin,

    A few people asked about sybase support already — I do not expect that implementing that would be more then a few hours of effort if someone knows how to use sybase. My problem is that I don’t have a test server for sybase and have never used it, so I cannot implement that. If you would be interested in helping out (or perhaps get someone from your company to do it), I would be glad to help.

  121. Marisaon 07 Feb 2008 at 6:36 pm

    Hi Gojko,

    I tried to use ConnectUsingFile but got an error about my connection string value. I’ve tried specifying the connection string in the following ways, but got the exception each time.

    connection-string=Data Source=ourServerName;Initial Catalog=ourDBname;Integrated Security=True
    connection-string=Data_Source=ourServerName;Initial_Catalog=ourDBname;Integrated_Security=True
    connection-string=server=ourServerName;database=ourDBname;uid=username;pwd=password

    This is the exception I get with any of the above connection strings:

    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
    at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue)

    I’m sure I just don’t have the connection string in the right format – the page on fitnesse.info http://fitnesse.info/dbfit:connection_properties_file states to use a “full ADO.NET connection string” – I Googled for that and couldn’t really find a “spec” for that.

    Thanks for your help!

  122. gojkoon 07 Feb 2008 at 11:13 pm

    Hi Marisa,

    SQLServerEnvironment uses this format for the connection string

    data source={0};user id={1};password={2};database={3};

    so the equivalent of specifying properties individually would be something like

    data source=ourDbServer;user id=dbfitDbUser;password=dbFitDbPassword;database=testDb;

    That format should work for you. let me know if it does not and i’ll add some troubleshooting info to that method.

  123. Kevinon 12 Feb 2008 at 3:46 pm

    Hey gojko,

    If you need help testing sybase support in .net/java, i’d be happy to test or do whatever is needed on our local sybase server. let me know.

  124. gojkoon 12 Feb 2008 at 3:51 pm

    Hi Kevin,

    yes – that’s one of the things I need to implement sybase support (thanks for offering to help). We also need someone who knows his way around sybase internals, especially how to retrieve meta-data about table columns and procedure parameters.

  125. Marisaon 14 Feb 2008 at 10:35 pm

    Hi Gojko,

    I searched the DbFit source code and it looks like VarBinary is supported – but when I try something like the following, I get strange results:

    !|Query|SELECT CAST(‘junkjunkjunk’ AS VARBINARY) AS VarbinValue|
    |VarbinValue?|
    |>>myValue|

    What gets stored in myValue is “System.Byte[]”

    I’ve tried a few different things but can’t seem to get this working (it works in a SQL query window though).

    Thanks for your help.

  126. gojkoon 14 Feb 2008 at 11:51 pm

    Hi Marisa,

    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.

  127. Marisaon 15 Feb 2008 at 12:21 am

    OK that makes sense…and the symbol works fine in the rest of the test page.

    Thanks!

  128. Haxenon 18 Feb 2008 at 4:53 pm

    Insert and null values.

    I would like to setup known data in my SQL2005 with dbFit. To make it look like liva data I need to insert null values to several columns. I just can’t find out if it’s possible and if it is how to? I get an error message if a column is empty ‘Cannot use input parameters as output values. Please remove the question mark after ‘.

    Thanks

  129. gojkoon 18 Feb 2008 at 7:04 pm

    Hi Haxen,

    I have not heard anyone else complaining about inserting nulls. The error would suggest that you are doign an insert into a column that has a question mark in the header. question marks are used to signal output (i.e. columns with automatically generated IDs that should be populated into symbols). Can you paste your FitNesse table here?

  130. Haxenon 19 Feb 2008 at 8:11 am

    Sure Gojko,

    !|Insert|cmtyUsers|
    |FName|LName|RegistrationStep|COAddress|Address|ZipCode|City|CellPhone|Phone|
    |Test|User|4||Snickargatan 5|90360|||703980395|

    Is it because the camelcased column names?

  131. gojkoon 19 Feb 2008 at 8:27 am

    Hi Haxen,

    In FitNesse, empty cell generally means “print the current value, don’t test”. I guess that’s why you get the message that the input parameter (insert value) cannot be used for output. The error message is wrong, and I’ll look into how to disable this functionality for inserts. You should be able to use the keyword NULL to insert nulls. try

    !|Insert|cmtyUsers|
    |FName|LName|RegistrationStep|COAddress|Address|ZipCode|City|CellPhone|Phone|
    |Test|User|4|NULL|Snickargatan 5|90360|NULL|NULL|703980395|

    it’s definitely not because of camelcased names, since column names are case insensitive.

  132. Marisaon 20 Feb 2008 at 5:13 am

    Hi Gojko,

    I have a question about the following excerpt from the PDF:

    * Test suite includes and initialisations can be added to either SuiteSetUp or SetUp – however, I
    strongly suggest using SetUp for that – this makes sure that the environment will be properly
    initialised for all the tests if they are executed separately. In some versions of FitNesse,
    SuiteSetUp will not be run when you execute individual test pages in the suite.
    * Only the actions that really have to be executed once and only once for the entire suite run
    should be added into SuiteSetUp.

    I am reorganizing our suites right now and wanted to try to put the DbFit connection on the main SuiteSetUp page – I verified that individual tests still work because SuiteSetUp is run prior to the test (b/c I have the latest version of FitNesse). However, Running the suite causes exceptions such as — “Type ‘executeprocedure’ could not be found in assemblies.”

    It appears as though the DB connection is lost after exiting the SuiteSetUp page – is this what you would expect? (Is that why you suggested that the DB Connection is put on the SetUp page instead?)

    Thanks for your help.

  133. gojkoon 20 Feb 2008 at 9:35 am

    I would imagine that SuiteSetUp is executed as a full, separate page. That would cause the connection to be closed and transaction rolled back on the end. I suggest using SetUp/TearDown to prepare the connection – they are executed as part of the test page, not as a separate page.

  134. Vipreshon 21 Feb 2008 at 7:31 am

    In reply to wat Johannes said in Coment number 45
    I got the create procedure workin by doin som thing lik this, but I had to spend a lot of time aariving at this hack. It now aalows me to create procedure which has variabls declared

    !|execute|!-exec (‘create proc TestUtil_DropCampaignDisplayTables
    as
    declare @campaignDisplayTables TABLE (
    rowID int identity (1,1),
    tableName varchar(250)
    ) ;
    insert into @campaignDisplayTables select name from sys.tables where name like ”%_Campaign_Display%”;
    declare @CurrentRowId int;
    declare @NoOfRows int;
    declare @TableName varchar(250);
    select @NoOfRows=isnull(count(*),0) from @campaignDisplayTables;
    if(@NoOfRows>=1)
    begin
    set @CurrentRowId=1;
    while(@CurrentRowId<=@NoOfRows)
    begin
    select @TableName=TableName from @campaignDisplayTables where rowId = @CurrentRowId;
    exec(”drop table ['' + @TableName+'']”);
    set @CurrentRowId=@CurrentRowId+1;
    end
    end’)-!|

  135. Vipreshon 21 Feb 2008 at 9:48 am

    How can I create tables with dynamic names for eg.
    We have tables that get created evry day which are prefixed with dates for eg. (20070221_Campaigndisplay).

    We have another RaiseInvoice procedure which picks up rows from this daliy table and enters the rows in Transaction tables and renames this daily table.
    So for testing the RaiseInvoice procedure I needed to create setup data through DBFit test so for doin this I needed to created dialy tables with date appended, the only hack I could find out was this way.
    I have not added the actual column names of the daily tables to keep it simple.

    |Query| select getdate() + ‘_Campaign_Display’ as yesterdaystablename, ‘done_’ + getdate() + ‘_Campaign_Display’ as Donetablename |
    |yesterdaystablename?|Donetablename?|
    |>>fetchedTable|>>doneTable|

    !|Query| Exec ( ’select 1 as RR;create table ‘ + @fetchedTable + ‘ (id int)’)|
    |!-RR-!|
    |1|

    !|Query| Exec ( ’select 1 as RR;create table ‘ + @doneTable + ‘ (id int)’)|
    |!-RR-!|
    |1|

    may be there is som better way of doin this

  136. gojkoon 21 Feb 2008 at 10:29 am

    Hi Vipresh,

    you can use markup variables to do that. Markup variable is a pre-processing macro, so you could do something like this

    !define currentdate {20070221}

    !|execute|create table ${currentdate}_campaign_display …|

    you can initialise a variable from the properties file or operating system environment (use -D in the run.bat file that starts fitnesse).

    Please note, however, that I would recommend changing this approach to a single table that has a date column, possibly partitioned by dates if you want to split storage. Using tables like this is very strange.

  137. Haxenon 22 Feb 2008 at 8:04 am

    Thanks Gojko,

    Sorry for the late reply but it worked out with the NULL keyword. That was what I was looking for, is it in the doc’s?

  138. gojkoon 22 Feb 2008 at 10:15 am

    Null keyword is in fitnesse docs. I’ll add more about it into the new dbfit docs as well.

  139. Marisaon 25 Feb 2008 at 3:35 pm

    Hi Gojko,

    I am seeing strange behavior in a particular case – can you please let me know if I am doing something wrong?

    When I try to insert a value into an NTEXT column using the Insert fixture, the value is truncated to 16 chars:

    !|Insert|MyTable|
    |RecordID|ContentNtext|
    |123|This is some content that is longer than 16 chars.|

    The following fails:

    !|Query|SELECT ContentNtext FROM MyTable WHERE RecordID = 123|
    |ContentNtext?|
    |This is some content that is longer than 16 chars. EXPECTED|
    |This is some con ACTUAL|

    If I use !|Execute|INSERT INTO(….| then the value is NOT truncated, so I can use this method instead but just wondered why I can’t use the Insert fixture. Thanks for your help.

  140. gojkoon 26 Feb 2008 at 8:14 am

    Hi Marisa,

    It may be reading incorrect meta-data for that type. I had issues with some other string types in the past where the length column was not reliable. I’ll change NTEXT to ignore the metadata size and always use maximum supported size today.

  141. Vipreshon 27 Feb 2008 at 7:38 am

    HI Gojko , Thnkz for reply
    !define doesnt solve my problem
    Cauase I wanna to have the table created with current date
    If I use “!define currentdate {20070221}” the date will be hard coded , wat I want is when ever the dbfit test is executed I want table created for that date.

    The reason for doin this is because I hav another stored proc GetDailyCampaignTables which picks up all the temporary tables which have date(prefixed in table name) less then current date .
    So I can hav a test which creates these daily tables with diff dates and then I can make differebt asserts on Resultset retuirned by GetDailyCampaignTables.

    And can u plz giv me example of how to initialize variable from the properties file or operating system environment I could’nt find any complete examples on that subject.

  142. gojkoon 27 Feb 2008 at 8:05 am

    You can initialise a variable from the operating system by using -D in the java command line that starts fitnesse.

  143. Kevinon 27 Feb 2008 at 7:56 pm

    Hey Gojko, i’ve got a couple bugs to report :)

    In the .NET version of dbfit, parameterized values for queries dont work (ie, setting a parameter like so:
    |set parameter|var|value| and referencing it as :var), at least for the Query fixture (havent tried it in any others).

    Also, |set parameter|..|..| onlt works in flow mode, not standalone mode (i’m not sure if this is a bug or a design decision, but it was confusing to me when i read through the documentation).

    Could you take a look? I’d appreciate any help with this you could provide at your convenience. Thanks!

  144. gojkoon 27 Feb 2008 at 8:34 pm

    Hi Kevin,

    I’ve just double-checked, my acceptance tests for Oracle and parameters in Query are working ok, which means that either my acceptance tests don’t cover your case, or that you are using a different case for the parameter in “set parameter” and “query”. “set parameter” by default manipulates only strings, and if your query is expecting a number or a date, that might cause a problem as well. Could you please send me the fitnesse page so I can test here (with a query against dual or the table/view definition for what you are querying against)

    Regarding set parameter and standalone – my original idea was that people would use standalone fixtures if they want to manipulate fixtures directly, so I did not think that I need to provide an additional fixture for symbol manipulation. Several people asked about that, so I’ll add it to the next release. Meanwhile, you can use StringFixture to do it.

    |StringFixture|
    |field|field?|
    |my value|>>paramname|

    (similar fixtures exist for other types as well).

  145. gojkoon 27 Feb 2008 at 8:35 pm

    Kevin – btw, I see from your earlier posts that you are using SqlServer. If that is the case, Query expects parameters to be in the Sql Server style (@paramname) not in the oracle style (:paramname).

  146. Kevinon 27 Feb 2008 at 8:44 pm

    Ah, that was the problem (: where it should be @). i originally thought that parameters were handled within dbfit instead of by the sql backend itself. good to know :)

    oh also, i switched over to flow mode to utilize the set parameter function since it doesnt matter for the tests i’m currently running.

    Thanks for your help!

  147. Vipreshon 28 Feb 2008 at 3:56 pm

    I m using Sql Server
    How do I execute Scalar valued function using !|Execute Procedure| fixture
    When I do !|Execute Procedure|ConcatenateF| I get System.ApplicationException: Cannot read columns/parameters for object [concatenatestrings_f] – check spelling or access privileges
    This is because scalar valued functions hav to be executed using two part name i.e dbo.FunctionName
    Can u plz tell me if I can use !|Execute Procedure| fixture for testing Scalar valued functions.

  148. gojkoon 28 Feb 2008 at 4:02 pm

    Hi Vipresh,

    have you tried to do

    !|Execute Procedure|dbo.ConcatenateF|

  149. Vipreshon 29 Feb 2008 at 9:18 am

    yes Gojko,
    I tried all the options
    !|Execute Procedure|dbo.ConcatenateF|
    !|Execute Procedure|[dbo].[ConcatenateF]|
    !|Execute Procedure|[dbo.ConcatenateF]|
    !|Execute Procedure|!-dbo.ConcatenateF-!|
    !|Execute Procedure|!-[dbo].[ConcatenateF]-!|
    !|Execute Procedure|!-[dbo.ConcatenateF]-!|
    !|Execute Procedure|!-[dbo]-!.!-[ConcatenateF]-!|

    But with no sucess

  150. gojkoon 29 Feb 2008 at 10:27 am

    Hi Vipresh,

    can you send the complete fitnesse page that you are running, along with the versions of the database server and dbfit. Ideally, if you could also send the source code for the procedure, that would help.

  151. Vipreshon 03 Mar 2008 at 8:13 am

    Sori Gojko but I got the function working. I had created the function on wrong DB

  152. Kevinon 03 Mar 2008 at 7:15 pm

    Hey Gojko,

    is there any plan to offer a compiled current version of DBFit against the new Fitnesse.NET 1.5? it seems that when i upgrade that DLL dbfit breaks. Not a huge issue, just wondering if there’ll be an official release against 1.5.

  153. gojkoon 03 Mar 2008 at 7:18 pm

    Hi Kevin,

    1.0 (which will be released soon) will be compiled with 1.5

  154. gojkoon 06 Mar 2008 at 1:43 am

    Hi Kevin,

    DbFit now compiles with FitNesse.NET 1.5. Get the latest beta from

    http://dbfit.svn.sourceforge.net/svnroot/dbfit/dbfit/dist/dbfit-dotnet-20080305-fdn15.zip

  155. Kevinon 14 Mar 2008 at 5:04 pm

    Hi Gojko,

    I’m happy to report that dbfit 1.0 works great in the tests i have so far :) . I have one question related to a future feature though for sql server environments at least (oracle/mysql if they support this too). Is there a plan on supporting image data types that live in sql server tables? i know that fitnesse .net doesn’t have the imagefixture implemented from the java version (or it didnt last i checked) so this feature may be difficult to implement easily, but it would be nice to either show images in the browser or at least show the base64 encoding of an image or something similar, since right now querying an image column in a table just shows System.Byte[].

    It’s not a requirement for us at this point, just an idea for an enhancement i thought up for when you can get around to it if you want to do it :) .

  156. gojkoon 14 Mar 2008 at 5:16 pm

    Hi Kevin,

    I generally put in support for data types when someone requests them. If Image column comes up as System.Byte[], then it’s most probably an alias for binary or varbinary – they are converted to System.Byte[] in dbfit. You can test them with 0xHEXVALUE syntax if you load up the appropriate handler. See BinaryTests acceptance test for an example.

    I’m not sure how the image check would work with the .NET test runner directly, but I’ll investigate that.

  157. Michel Sabourinon 08 Apr 2008 at 1:09 am

    Hi Gojko,

    We started to look at integrating acceptance tests in our .NET development (thanks to your book “Test Driven .NET Development With FitNesse”) and I must say I’m very enthusiastic. I would like to propagate this enthusiasm to our “legacy code” development teams. My problem is that we use DB2 for iSeries and no support is provided for DB2 in DbFit :(
    What kind of effort does it suppose to implement this?

    Thanks.

  158. gojkoon 08 Apr 2008 at 8:27 am

    There is some initial support for DB2, and that is under development currently. I’ll upload the first version soon.

  159. Michel Sabourinon 09 Apr 2008 at 12:50 am

    Thank you for your support. Anything I could do to help?

  160. gojkoon 09 Apr 2008 at 9:26 am

    Hi Michael,

    not at this moment, but once I merge the initial DB2 support with the main code you can help by testing.

  161. Gary Coleson 09 Apr 2008 at 10:59 am

    Hi Gojko

    I am testing DBFit at the moment to see if it will work for our unit testing. I was just doing some simple test to start with to try and get to understand how it works. I have come up against an issue straight away. I am having problems inserting more than 1 row. Below is the test code I am using. Can you see anything to suggest why it only inserts one row.

    !path lib/*.jar
    !|dbfit.OracleTest|
    !|ConnectUsingFile|BOSS3DBConnection.properties|
    !2 Blacklisting full cross carrier stored procedure test cases
    !3 Drop old table and create new table
    |execute|drop table gary_coles.gary_2|

    |execute|create table gary_coles.gary_2(carrier_event_id number(18) not null, external_id number(10) not null, carrier_event_type_id number(18) not null, event_date date not null, file_id_creating number(18), file_id_export number(18), carrier_id number(18) not null, msisdn_new varchar2(4000), msisdn_old varchar2(4000), equipment_id_new varchar2(4000), equipment_id_old varchar2(4000), real_network_id_new varchar2(4000), real_network_id_old varchar2(4000), creation_date date default sysdate not null)|

    !3 Inserting test data for test case id 1 and 2
    |insert|gary_coles.gary_2|
    |carrier_event_id|external_id|carrier_event_type_id|event_date|file_id_creating|
    file_id_export|carrier_id|msisdn_new|msisdn_old|equipment_id_new|
    equipment_id_old|real_network_id_new|real_network_id_old|creation_date|
    |9999001|9999001|3|2008-04-09 00:00:00|1|1|10003|null|9370624691|null|0000|null|12344444|2008-04-09 00:00:00|
    |9999002|9999002|2|2008-04-09 00:00:00|1|1|10003|null|9370624691|null|0000|null|12344444|2008-04-09 00:00:00|

    !3 Check to see if records were inserted into the table
    |query|select carrier_event_id, external_id, carrier_event_type_id, event_date, file_id_creating, file_id_export, carrier_id, msisdn_new, msisdn_old, equipment_id_new, equipment_id_old, real_network_id_new, real_network_id_old, creation_date from gary_coles.gary_2 where carrier_event_id between 9999001 and 9999013|
    |carrier_event_id|external_id|carrier_event_type_id|event_date|file_id_creating|
    file_id_export|carrier_id|msisdn_new|msisdn_old|equipment_id_new|
    equipment_id_old|real_network_id_new|real_network_id_old|creation_date|
    |9999001|9999001|3|2008-04-09 00:00:00|1|1|10003|null|9370624691|null|0000|null|12344444|2008-04-09 00:00:00|
    |9999002|9999002|2|2008-04-09 00:00:00|1|1|10003|null|9370624691|null|0000|null|12344444|2008-04-09 00:00:00|

    Cheers
    Gary

  162. Gary Coleson 10 Apr 2008 at 8:34 am

    Hi Gojko

    I have a store procedure that returns a PLS_INTEGER out of Oracle and I have noticed that DBFit doesn’t support Binary Integer datatypes. Is it possible to get DBFit to except them please.

    Cheers
    Gary

  163. gojkoon 11 Apr 2008 at 8:44 am

    Hi Gary,

    PLS_INTEGER support is now built into the latest beta – please get it from http://dbfit.svn.sourceforge.net/svnroot/dbfit/dbfit/dist/dbfit-20080411.jar and test.

    Regarding your previous example, with insert putting in one row: I’ve just tried to repeat the test on my system and it works OK. Check how the insert table looks on the screen – if there are any blanks
    after the closing | in one of the rows, that row should look formatted differently and fitnesse will not execute it as part of the same table. double-check that the last line on the page is blank (if you page ends with the | on the last line, add a line break after that). that may be the reason why it is not being inserted. If everything looks ok, which version of oracle/dbfit/fitnesse are you using?

  164. gojkoon 21 Apr 2008 at 1:58 am

    Initial DB2 support is now available for Java – get the latest beta build from SourceForge. For examples and usage info, see acceptance tests folder in the wiki. Here is an example how to connect and start the session:

    !|dbfit.DB2Test|
    
    !|Connect|localhost:50000|DFTEST_USER|DFTEST_PWD|DBFIT_DB|
    
  165. vickion 22 Apr 2008 at 1:43 pm

    I’ve just started to use dbfit and am quite impressed. However, I have come across an issue where it can’t find a package if the package name contains a $ (dollar) symbol.

    Basically, I have a stored procedure I wish to call and it is contained within a package called somepackage$pkg. When I use the line:

    !|Execute Procedure|somepackage$pkg.createsomedata|

    I get an error

    System.ApplicationException: Cannot read list of parameters for somepackage$pkg.createsomedata- check spelling and access privileges
    at dbfit.OracleEnvironment.GetAllProcedureParameters(String procName) in D:\work\dbfit\impl\dotnet\src\environment\OracleEnvironment.cs:line 68
    at dbfit.fixture.ExecuteProcedure.InitParameters(Parse headerCells) in D:\work\dbfit\impl\dotnet\src\fixture\ExecuteProcedure.cs:line 117
    at dbfit.fixture.ExecuteProcedure.DoRows(Parse rows) in D:\work\dbfit\impl\dotnet\src\fixture\ExecuteProcedure.cs:line 43
    at fit.Fixture.DoTable(Parse table)
    at fitlibrary.FlowFixtureBase.ProcessRestOfTable(Fixture theFixture, Parse theRestOfTheRows)

    It isn’t a problem with the connection or stored procedure as it executes through dbfit if I create another package (with no $ in the name) and call the stored procedure via that new package.

    I am running the .net version of dbfit and the database is an Oracle 11g instance.

    Any ideas on how this can be resolved? Can I put some kind of escape characters in so the $ is recognised? I don’t want to have to rename the package as it is a legacy package and used all over the place. Or is this an issue in dbfit?

  166. gojkoon 22 Apr 2008 at 2:00 pm

    Hi Vicki,

    the $ is intentionally removed during name cleanup and normalising. The fix is fairly easy to do, I’ll add it to the next version. Meanwhile, you can create a synonym for your package and use the synonym.

  167. mark meyerson 26 Apr 2008 at 4:10 pm

    hello gojko,

    I’m having a problem passing the dbfit connection to my data components. Could you point me to an example of how to acomplish this. My data components take a dbconnection in their constructor. But I can’t seem to get a hold of the dbfit connection without changing the source code.

    Love the library though. Great stuff. I’ve extended it (very basic just now) to support SqLite for in memory testing when I’m at home.

    Mark

  168. gojkoon 26 Apr 2008 at 4:46 pm

    Hi Mark,

    I’ve exposed the current connection and transaction now as public properties. Please get the new binaries from dbfit-dotnet-20080426.zip. This will be included in the next release so you don’t have to worry about breaking compatibility.

  169. mark meyerson 26 Apr 2008 at 6:55 pm

    Swift response. Thx. Still one problem : How do I obtain an instance to AbstractDbEnvironment in my fixture code ?

  170. gojkoon 26 Apr 2008 at 10:39 pm

    Hi Mark

    First, to use the connection outside dbfit, you have to be using the standalone mode. After you connect to the database using DatabaseEnvironment fixture with an argument to specify which kind of DB you are using, dbfit.DbEnvironmentFactory.DefaultEnvironment will become initialised. You can also init it yourself by creating the appropriate IDbEnvironment instance and assign it to that property. DbFit fixtures will then use it.

  171. mark meyerson 27 Apr 2008 at 6:43 am

    Hi Goyko

    This works fine for the supported environments (by the dotnet version). If I want to use a custom environment (f.i. SqLite) I would have to define a class that derives from DatabaseEnviroment and override the DoTable member. The ApplicationException that is thrown if the environment is not known forces me to duplicate the code of DatabaseEnviroment.DoTable in MyDatabaseEnviroment.DoTable.
    Just to show you what I’m trying to do :
    —-
    Page One : ConnectToOracle :
    !|dbfit.OracleTest|

    !|Connect|${TNSName}|${UserId}|${Password}|
    —-
    Page Two : ConnectToSqLite :
    !|dbfit.SqLiteTest|

    !|Connect|:memory:|||

    … the necessary CREATE TABLE statements, etc for the in-memory database.
    —-
    Then in my setup page I can choose which one to include and switch between environments. This allows me to ascertain db type independance (a project requirement). As well as switching between integrated testing (the oracle version) and a more unit-testing like approach (the SqLite version) as the in memory database runs in the pages process not affecting other users also running the tests. The in-memory database tests also execute fast enough to be used in a TDD cycle. So I don’t want to build this logic in the fixture code as this seems a lot more complicated than what I do now. I.e. to switch all I have to do is change ‘!include <DataRepository.ConnectToSqLite’ to ‘!include <DataRepository.ConnectToOracle’ on my setup page.
    This can be made to work by changing the AbstractDatabases attributes CurrentConnection and CurrentTransaction to ’static public’. But this solution might smell a bit, although I think it works as each page runs in a seperate context and you can only have one dbfit connection per page.

    Mark

  172. gojkoon 27 Apr 2008 at 9:41 am

    Hi Mark,

    if you use

    !|dbfit.OracleTest|
    

    then DefaultEnvironment is not initialised. Those are flow-mode tests. If you want to use the same database connection in your fixtures, then you have to use the standalone mode:

    (first page)

    !|DatabaseEnvironment|ORACLE|
    |Connect|....|
    ....
    
    !|DatabaseEnvironment|
    |Rollback|
    

    (second page)

    !|Your init fixture|
    
    !|DatabaseEnvironment|
    |Connect|....|
    ....
    
    !|DatabaseEnvironment|
    |Rollback|
    

    DatabaseEnvironment fixture works by either using the default environment (if no argument is given) or setting the default environment (if it has an argument). So in the second page, do not call DatabaseEnvironment first but instead call your own fixture that will initialise SqlLiteEnvironment and set DefaultEnvironment to that instance.

    Another option is to extend DatabaseTest so that it can work with either oracle or sqllite environments (based on some parameter) and add methods that initialise your fixtures and pass the current environment. this would allow your fixtures to work in flow mode tests so you do not have to rollback manually.

    see Connecting to the database from DBFit reference and Standalone and flow mode comparison from Fitnesse.info for more information on flow and standalone modes.

  173. Stephenon 30 Apr 2008 at 8:36 pm

    I’m new to dbfit and just picked on dbfit a couple of weeks ago. I’m having problems figure out the error below.

    !path lib/*.jar

    !|dbfit.OracleTest|
    !|Connect|xxxxx:1234|userid|pass|db1| #not the real info

    !|insert|company|
    |id|
    |900000|

    !|update|company|
    |address|id|
    |1234 S|900000|

    I’m getting the error: Cannot retrieve list of columns for company_can_pop – check spelling and access rights

    I have verified that everything is spelled correctly. The all_* views/tables are public.

    Any other ideas?

    Thanks

  174. gojkoon 30 Apr 2008 at 9:37 pm

    Hi Stephen,

    is the table in the schema of that user from the “connect” command ? if not, you may need to add a schema prefix to the table name. It’s weird that DbFit complains about “company_can_pop” and not “company” – for some reason it is looking for a company_can_pop table. Can you send me your whole test page?.

    Just to make sure that DB privileges are not causing problems, please connect to the database under the credentials of the user from your “connect” command and execute this query:

    select column_name, data_type, data_length, ‘IN’ as direction,
    column_id from all_tab_columns where
    (owner=user and table_name=’COMPANY’) order by column_id

    do you get a list of columns or some security error?

    Also, i’d expect that you want to put some columns with = in the update command (although that should not cause the problem that you have). Which version of DbFit are you using?

  175. Stephenon 01 May 2008 at 3:30 pm

    Thanks, that worked.

    I’m using 1.0.

    I have a couple of more questions.

    1. Is there a delete option? I noticed that insert, update, query can be used but not delete.

    2. Is tear down an option in dbfit?

    Thanks

  176. gojkoon 01 May 2008 at 3:39 pm

    Hi Stephen,

    1. there is a “clean” fixture, but I consider that deprecated and don’t think that it will be updated any more. You can use

    |execute| delete from tablename where somefield in (:sym1, :sym2…)|

    and delete rows from the table by symbols.

    2. there is a teardown option in FitNesse, just call the page TearDown.

  177. Milenon 12 May 2008 at 2:50 pm

    Hi,

    I am trying to store properties of a connection to a SQL Server 2005 database in a file. I want to use integrated security, so I use the connection-string property declared in the file as as:

    connection-string=Integrated Security=true;Initial Catalog=AdventureWorks;Server=MSSQL1

    When I run the test I get the following exception:
    System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.

    I looked at the DbFit code and I found that the DbConnectionProperties::CreateFromString method is splitting the line in tokes separated by ‘=’. In the above example that will result in the following tokens stored in array keyval:

    connection-string
    Integrated Security
    true;Initial Catalog
    AdventureWorks;Server
    MSSQL1

    Then the method checks the contents of keyval[0] and if it equals “connection-string” then it puts the value that is stored in keyval[1] in the FullConnectionString property. If we take the example connection string that would send a connection string of “Integrated Security” to the SqlConnection.set_ConnectionString and will result in the exception that I am experiencing. I tried to figure another way of connecting to a database using integrated security while keeping the connection string in a file but I couldn’t. Do you know of a workaround or do I have to wait for the fix?

    Best regards,
    Milen

  178. gojkoon 12 May 2008 at 11:44 pm

    Hi Milen,

    Thanks for noticing this. The fix is committed to the source code repository, and will be part of the next regular release. You can get the nightly binary build with the fix from the dist folder (dbfit-dotnet-20080512.zip)

  179. Milenon 14 May 2008 at 6:41 pm

    Hi Gojko,

    While testing a stored procedure in SQL Server 2005 that returns a decimal(15, 5) in one of its output parameters using the Execute Procedure command, I found that DbFit rounds the value passed as output in the parameter. While the check value in my test table is correct, DbFit compares it with the incorrect rounded value and the test fails. That does not happen if I insert the data into a table and then test the contents of the table via Query command. Is that an anomaly of the Execute Procedure command or am I missing something?

    Best regards,
    Milen

  180. gojkoon 14 May 2008 at 9:22 pm

    Hi,

    from your description, this is most likely a bug in the type mappings. Can you write a small example (stored proc + dbfit tables) that demonstrates the problem and i’ll fix it and add the example to acceptance tests for the future.

  181. Milenon 15 May 2008 at 1:22 pm

    Hey Gojko,

    Here’s the stored procedure:

    create procedure TestDecimal
    @inParam decimal(15, 8),
    @copyOfInParam decimal(15, 8) out,
    @constOutParam decimal(15, 8) out
    as
    begin
    set @copyOfInParam = @inParam
    set @constOutParam = 123.456;
    end

    And here’s the DbFit test page:

    !define COMMAND_PATTERN {%m %p}
    !define TEST_RUNNER {dotnet2\FitServer.exe}
    !define PATH_SEPARATOR {;}
    !path dotnet2\*.dll

    !|dbfit.SQLServerTest|
    !|Connect|Data Source=localhost\SQL2005;Initial Catalog=DbFitTest;Integrated Security=True;|

    !|Execute Procedure|TestDecimal|
    |inParam|copyOfInParam?|constOutParam?|
    |3.14|3.14|123.456|
    |0.79|0.79|123.456|

  182. Milenon 15 May 2008 at 1:24 pm

    The smiley sun glassed faces above are in fact “8)”

  183. gojkoon 16 May 2008 at 11:17 am

    Hi Milen,

    the bug is fixed in dbfit-dotnet-20080516.zip. I have added your test to the acceptance test suite. Thanks for spotting this.

  184. Milenon 20 May 2008 at 1:47 pm

    Hey Gojko,

    I am maintaining database creation and configuration SQL scripts and I wanted to express them in DbFit fixtures tables while at the same time having SQL scripts to run against the database. That would make my scripts difficult to maintain due to duplication. I was thinking, wouldn’t it be useful for the fixtures to be able to generate the SQL in whatever dialect is currently set for the page and have a way to produce a wiki page or text files with the SQL? For example, an INSERT command could generate the SQL INSERT statements; EXECUTE PROCEDURE could generate the calls to the procedure, etc.

    Best regards,
    Milen

  185. gojkoon 21 May 2008 at 11:55 am

    Hi Milen,

    I can add a “debug” option to dbfit that would allow you to print out any sql statements executed to the “output captured” screen that you can get after running tests. Would something like this help?

  186. Milenon 21 May 2008 at 1:08 pm

    Hi gojko,

    Yes, that would help. In my scenario it would be great if I could automatically generate the SQL scripts files and run them against the DB. The whole project is under continuous integration (CruiseControl.NET). Currently I am running the DbFit fixtures in CC.NET, but for deployment on production I need the bare SQL so any way to get the SQL out of the fixtures would help. I guess if we had the “debug” option I would be able to tap into the output stream and capture the SQL. I think having a wiki SQL page per fixture page would be really nice, however I can see how that could be difficult to implement without running the fixtures.

    Thanks,
    Milen

  187. Johanon 28 May 2008 at 8:33 am

    Hi!

    Within a test I need to execute a SQL query in an external .net fixture (flow mode). Is there any way that I can send the open connection object to this external fixture (so that it will execute within the same transaction as the test)?

    What I’m trying to achive is a conditional timeout where the condition is defined as a SQL query. If I could do this within the same transaction as the rest of the test I would achieve a more realistic test case.

    Thanks//J

  188. gojkoon 28 May 2008 at 9:34 am

    Hi Johan,

    you can extend DatabaseTest and add your method (and pass the correct environment object to the base class constructor). Alternatively, you can extend the concrete subclass that you are working with (SqlServerTest or OracleTest) and just add your method. The environment field is protected in DatabaseTest so you will be able to access it from the new method (see DatabaseTest source). That will allow you to re-use the same connection. The other option is to use the standalone mode.

  189. Pål Brattbergon 28 May 2008 at 2:29 pm

    Hi there and thanks for an excellent product!

    In our current project we require support for the Derby database and I have developed a DerbyEnvironment for this along with acceptance tests and junit tests.

    If you’d be interested in having this as part of the normal distribution we’d be happy to donate the code.

    Please contact me for more information on how we could accomplish this if it sounds interesting.

  190. Michel Sabourinon 28 May 2008 at 5:08 pm

    Hi Gojko,

    We managed to do the implementation of DBFit for DB2 for iSeries. It seems to be working OK except for few things, among them this one: We call a stored procedure which returns one parameter char(18). If we state in our test page that we expect to have this character string ‘ABCDEF’ in return, the test fails saying this:

    ABCDEF expected
    ABCDEF actual

    We managed to figure out that the actual value returned was ‘ABCDEF____________’ (the character string right-padded with 12 blanks). But we are unable to specify these blanks in the test page. The only way we found was this one :

    |!-ABCDEF____________-!|

    Is this the way it should work?

    Thank you.

  191. gojkoon 28 May 2008 at 5:31 pm

    Hi Michael,

    See section Working with padded chars in the Query command reference manual.

  192. Philippe Trottieron 29 May 2008 at 8:56 pm

    Hi Gojko,

    I work with Michel Sabourin on the DB2 for iSeries implementation of DBFit and while doing some tests on stored procedures I had a problem with one of my stored procedure in particular.

    It revealed that the SortAccessors() method in the ExecuteProcedure class was not doing its job well. So I made the change and just wanted to let you know the code I modified to make it work.

    So here is the full code of the SortAccessors method :

    private static DbParameterAccessor[] sortAccessors(DbParameterAccessor[] accessors)
    {
    DbParameterAccessor[] sortedAccessors = (DbParameterAccessor[])accessors.Clone();
    for (int i = sortedAccessors.Length – 1; i >= 0; i–)
    for (int j = 1; j sortedAccessors[j].Position)
    {
    DbParameterAccessor x = sortedAccessors[j - 1];
    sortedAccessors[j - 1] = sortedAccessors[j];
    sortedAccessors[j] = x;
    }
    }
    return sortedAccessors;
    }

    Thanx for your excellent product!

    Philippe

  193. [...] just in: you can now run FitNesse tests with DbFit using Derby/JavaDB as your database of [...]

  194. Vasily Kirichenkoon 04 Jun 2008 at 6:48 am

    Hi, Gojko!

    Although DbFit is a great thing to test databases, there’s a rather serious problem with using stored auto-generated ids in Query and Ordered Query.

    Here’s an example:

    !|Insert|DataCenter|
    |Name|IDDataCenter?|
    |DC1|>>dc_id|

    !|Ordered Query|select * from DataCenter|
    |Name|IDDataCenter|
    |DC1|<<dc_id|

    which produces strange result:

    |Ordered Query|select * from DataCenter|
    |Name|IDDataCenter|
    |DC1|33 <<dc_id expected 33 actual|

    If Ordered Query is replaced with Query, the result is even stranger:

    |Query|select * from DataCenter|
    |Name|IDDataCenter|
    |DC1|missing <<dc_id|
    |DC1|surplus 34|

    I use version 1.0 of DbFit.

  195. gojkoon 07 Jun 2008 at 8:42 pm

    @vasily
    bug with type mappings for smallint and bigint for inserts in sql server is fixed in build 20080608 .

  196. srinivason 09 Jul 2008 at 6:19 am

    hi..
    i have a doubt on servicefixture, as i seen database examples only on SQL, is it possible on oracle….,please send me examples fr oracle…
    send me 2 mail id..

  197. gojkoon 09 Jul 2008 at 6:24 am

    Hi srinivas,

    maybe contact the people that wrote the servicefixture? I had nothing to do with it.

  198. Nagaon 16 Jul 2008 at 11:57 am

    i have a doubt on giving oracle database connectivty for dbfit(webtest),
    can u pls tell me..

    username:3424cs
    password:dffggcs
    server name: url:jdbc:oracle:thin:@172.16.16.159:1521
    db name::orcl

    can u plz tell me for this..

  199. gojkoon 16 Jul 2008 at 12:33 pm

    |connect|172.16.16.159|3424cs|dffggcs|orcl|

  200. Nagaon 17 Jul 2008 at 4:08 am

    Thanks gojko..

    im new to this tool… let me know some basic examples..

  201. gojkoon 17 Jul 2008 at 8:42 am

    Hi Naga,

    see the DbFit reference

  202. John Vorison 30 Jul 2008 at 10:48 pm

    I would like to hear more about the work being done with DBFit for iSeries (aka. IBM ’s System i).

  203. Barrett Nuzumon 12 Aug 2008 at 4:47 pm

    fitnesse.org makes references to JdbcFixtures and provides the ability to execute an arbitrary block of PL/SQL with ScriptFixture. Unfortunately, Uncle Bob no longer provides any of that code.

    Would it be possible for DbFit to add the ability to execute blocks of sql?
    This would help when dealing with complex stored procedures (which, I admit, are a bad thing in general).

  204. gojkoon 12 Aug 2008 at 6:38 pm

    Hi Barrett,

    Use |Execute|Begin …. End;| to execute any pl/sql code. You can use !- and -! to do a multi-line statement. the latest beta version also allows you to escape the :param mapping to bind variables so that you can use even that in your code.

  205. Bradon 14 Aug 2008 at 6:16 pm

    Gojko,

    I’m using the version of DbFit from 2008-03-08.

    I guess I’m missing something fundamental, because I’ve tried to get standalone mode to work, and I can’t seem to get it to work.

    I have a set of stored procedure tests organized in flow mode on five different pages, plus a SetUp page. The setup page has the “dbfit.SqlServer200Test” fixture on it, with the connection string to get to the DB I’m testing. This page inserts a bunch of test data that the subsequent tests use for verifying the stored procs work. When I execute it in flow mode, all of the tests work.

    However, when I follow what I think are the instructions for changing it to standalone mode in the “dbfit:modes” page by changing teh SqlServer200Test fixture to something like the below,

    |import|
    |dbfit.fixture|

    !|DatabaseEnvironment|sqlserver2000|
    |Connect|Data Source=etc…;|

    along with:

    !|DatabaseEnvironment|
    |rollback|

    on the TearDown page, I get several exceptions, the first of which is one on the Set Parameter fixture which says that it “Couldn’t cast Set Parameter to Fixture”. I subsequently tried to do this:

    !|dbfit.util.Export|
    |dbfit.fixture|

    right after using the DatabaseEnvironment to connect. When I do that, I get a bunch of exceptions about “Type ‘query’ could not be found in assemblies”.

    Obviously, I’m doing something wrong here, but I don’t know what.

    What I really want to do, though, is simply get the actual IDbConnection object initialized by the SetUp page, and pass that to, or get access to it in, my fixture. Is there a way to do that? The object under test takes an IDbConnection as a constructor parameter, and that would make it simple to test if I could just pass in the one used by the pages.

    Brad

  206. gojkoon 14 Aug 2008 at 10:13 pm

    Hi Brad,

    there was a bug with SetParameter in that release, it has been fixed since. Get the latest beta from dbfit-dotnet-20080813.zip.

    If you want to mix your fixtures with DbFit, standalone mode is the way to go. Then read the current environment from dbfit.DbEnvironmentFactory.DefaultEnvironment.CurrentConnection

  207. Bradon 14 Aug 2008 at 11:30 pm

    Great, I’ll give it a shot. I guess my changes are the right ones then, aside from the “export” thing?

    Does that version of DbFit require any specific version of Fit or FitNesse?

    Again, thanks for putting DbFit together, and for the help.

    Brad

  208. gojkoon 14 Aug 2008 at 11:44 pm

    @Brad,

    the latest beta build is a pre-release of 1.1, linked with the latest versions of Fit.NET and FitNesse. If you need the set parameter fixture but do not want to integrate with the latest releases, just create one in your own namespace and use it. The source is here.

    Export effectively cancels the effects of import; so FIT will not automatically load fixtures from the dbfit.fixtures namespace after that table.

  209. Bradon 15 Aug 2008 at 12:29 am

    No, upgrading is OK. I just didn’t want to install the new DbFit into the old FitNesse wiki, and then wonder why it didn’t work. :)

    That just means I have to go find them, which I recall wasn’t that straightforward a task the last time I did it…

    Brad

  210. gojkoon 15 Aug 2008 at 8:51 am

    Hi Brad,

    Find what? Fitnesse (wiki) is on fitnesse.org. .NET fit runner is included with DbFit. See dbfit beta 1.1 for beta downloads.

  211. Bradon 15 Aug 2008 at 12:17 pm

    When I originally set up FitNesse, it was somewhat less than easy to find all the pieces I needed, until I used your “Getting Fit with FitNesse” document. That probably says more about me than the stuff I was looking for, but that’s OK.

  212. Willon 27 Aug 2008 at 3:11 pm

    Hi Gojko,

    I hope you can help. I have recently been looking at kicking off DbFit from the command line. I have located an article on a Fitnesse support site giving some instruction on how to acheive this, and so far so good. I can execute the test suites, however, none of the tests are successful, they only produce exceptions. After looking at the resulting HTML I found all tests to conclude to the same exception, ‘Could not find fixture: …’, this is the same for all fixtures, Query, Execute Procedure etc.. although this is not an issue when the tests are kicked off from a browser. So I must be missing something? Bellow is command I’m executing from the command line. Do I need to reference any other jar’s in the class definition?

    java -cp fitnesse.jar fitnesse.runner.TestRunner localhost 8085 FrontPage -html TestResults.html

    Thanks in advance

    Will

  213. gojkoon 27 Aug 2008 at 3:15 pm

    Hi Will,

    you need to add the dbfit and filtlibrary JARs to the classpath as well. You’ll find the appropriate versions in the dbfit-complete package of the latest release.

  214. Willon 27 Aug 2008 at 3:25 pm

    Thanks Gojko, I’ll give that a go, thanks for the speady response and a fantastic tool!

  215. Willon 28 Aug 2008 at 8:18 am

    Hi Gojko,

    I am still experienceing the same issue, even though I am including all of the appropriate JARs in the class path. Bellow is the line I am now executing.

    java -cp lib\fitnesse.jar;lib\fitlibrary.jar;lib\dbfit-20080822.jar fitnesse.runner.TestRunner localhost 8085 FrontPage -debug

    Thank you again for your help.

    Will

  216. gojkoon 28 Aug 2008 at 8:22 am

    Hi Will,

    can you send me the source of your FrontPage, root page (/root) and the output that you get by running TestRunner. You are missing the db driver jar (don’t know which db you are using). Send me the files by e-mail

  217. Gokulon 29 Aug 2008 at 8:14 am

    Hi Gojko,

    I am a beginner.I recently only started using DBFit. Its a wonderful tool. Congrats for that. I am able to execute queries or procedures correctly when i include the Dot Net files. But when i try to include the java files, it shows exceptions. It happens for both normal queries and procedures. I couldn find the reason. I don know if its because of any crazy mistake of mine. But Please help me out. Thanks in advance.

    Here is the result which i got :

    classpath: lib/*.jar
    dbfit.OracleTest
    Connect

    java.sql.SQLException: Listener refused the connection with the following error: ORA-12514, TNS:listener does not currently know of service requested in connect descriptor The Connection descriptor used by the client was: localhost at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at

  218. gojkoon 29 Aug 2008 at 8:26 am

    I Gokul, your error suggest that the connection string is wrong. Use the following form for Oracle/Java

    |Connect|host:port|username|password|database sid|

    See acceptance test set-up for an example.

  219. Gokulon 29 Aug 2008 at 8:37 am

    Hi Gojko,

    What is database SID? And my database runs in 127.0.0.1:8080.
    Pl help.

  220. gojkoon 29 Aug 2008 at 8:45 am

    your dba has to tell you that.

  221. Gokulon 29 Aug 2008 at 9:41 am

    hi,

    Gojko, i am just using it in my laptop and my database is oracle express edition 10g version. I am using DBFit jus to learn the concepts and the tool. What i want to know is, what is the full form of SID? How can i find it for my Database?

  222. gojkoon 29 Aug 2008 at 10:56 am

    In that case, it is most likely XE. Use this command to connect:

    !|dbfit.OracleTest|
    |Connect|localhost:1521|username|password|XE|

    the web console is running on 8080; your db is probably running on 1521

  223. Elizabethon 04 Sep 2008 at 5:14 am

    Hi Gojko,

    I’m using dbfit with SQL Server 2005 and I’m trying to execute a stored procedure that takes no parameters. This stored proc is just used as a getAll to fill a list. I am not having any success with “Execute Procedure” and can not find any information on how to run a stored proc without parameters. Our company would like to be able to test our stored procs and I have not been able to get this running.

    Thank you

  224. gojkoon 04 Sep 2008 at 8:46 am

    is your stored procedure returning data or not? if it is, then use something like this:

    !|Query|getAll|
    |col1|col2|col3|

    if it does not return anything, you can do

    !|Execute Procedure|getAll|

  225. Elizabethon 04 Sep 2008 at 1:55 pm

    Hi Gojko,

    The stored procedure is returning multiple rows of data. (in this case the proc returns 19 rows)

    I used

    !|Query|GetAllEmployers|
    |groupid|name|

    where I am just specifying the columns, and the results are as follows:
    Assertions: 0 right, 19 wrong, 0 ignored, 0 exceptions

    my stored proc is below:
    __________________________________________
    set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    go

    ALTER PROCEDURE [dbo].[GetAllEmployers]
    AS

    SET NOCOUNT ON

    SELECT groupid, [name]
    FROM groups
    ORDER BY [name]

    SET NOCOUNT OFF
    ________________________________

    Am I missing something?

    Thank you

  226. gojkoon 04 Sep 2008 at 2:04 pm

    do you want to test the output or not? if you are not concerned with testing the output, just with executing the procedure, use Execute procedure. to test the output, put the expected output in the table below column headings.

  227. Elizabethon 04 Sep 2008 at 4:47 pm

    Hi Gojko,

    Thank you for your help, I saw the error in my ways…

    I do have another question. Does dbfit handle tables that store data using “uniqueidentifier”? I tried to run another stored proc and received the following error:

    “System.ApplicationException: Can’t parse system.Guid because it doesn’t have a static Parse() method…”

    Will dbfit support system.Guid/uniqueidentifier?

    thank you

  228. gojkoon 04 Sep 2008 at 4:52 pm

    Hi Elizabeth,

    yes, dbfit supports guids. See DbFit FAQ and search for GUID. It would probably be useful to read the dbfit reference documentation if you plan to use it.

  229. Elizabethon 04 Sep 2008 at 5:11 pm

    Everything is working for me now. Thank you so much for your help. I really appreciate it.

  230. Jonathanon 17 Sep 2008 at 6:21 pm

    Hi Gojko,

    DBFit has been really helpful but I’m having some difficulty managing transactions from my test pages. I don’t want some queries to be involved in a transaction so I thought I could run the tests in stand-alone mode to prevent this. Following the steps from the online documentation, here’s what I did in wiki markup to check if a test was involved in a transaction. I’m using version 1.0.2008.310 of the dbfit.dll

    |import|
    |dbfit.fixture|

    !|DatabaseEnvironment|SQLSERVER|
    |Connect|server=MyServer; database=master; Integrated Security=SSPI;|

    The transaction count should be 0, but this test always fails and returns a tran count of 1.
    !|Query|select @@TranCount x|
    |x?|
    |0|

    Am I doing something wrong or is there a way from the Fitnesse test page, to explicitly prevent queries from being run inside a transaction?

    Thanks,
    Jon

  231. gojkoon 18 Sep 2008 at 9:25 am

    Hi Jon,

    dbfit will always run in a transaction, but in standalone mode you can include it in a wider transaction. You can commit and rollback from DbFit, though. To run a query without a transaction, you’ll have to implement a different dbenvironment instance that does not start transactions. what exactly are you trying to achieve with this, maybe there is a different solution?

  232. Jonathanon 19 Sep 2008 at 4:41 pm

    Hi Gojko,

    Thanks for the quick reply. The issue for me is one of DB resources. For example, let’s say on my test page that I want to compare the results of several procedures against each another. However, each procedure is expensive and runs for a long time (e.g. it contains multiple joins across very large tables). The concern I have is that if the entire Fit test page is executed in a single transaction, then all those procedures will be included in the transaction which will create memory and contention issues at the database level.

    Since I’m new to DBFit, maybe I don’t understand how transactions work at the test page level. If each test must run in a transaction, is there a way to make them run in separate transactions? Does each table on the page belong to a separate transaction or does the whole page run in a single transaction?

    Thanks,
    Jon

  233. gojkoon 19 Sep 2008 at 6:18 pm

    Hi Jon,

    you can use commit or rollback commands to end a transaction and start a new one. use store query to save results of a query and detach it from the current transaction, and compare stored queries to verify it later.

  234. Johanon 25 Sep 2008 at 2:34 pm

    Hi Gojko

    Do you have any experience in running tests using the dotnet testrunner? And more specifically, the output format? Whatever I do, the output (saved to a file) is always html formatted. And if I try to reformat it with the FormattingOption to xml, this output is just pretty much just placed within -tags which is about as useful as the html is in the first place.

    So, I suspect that I’m not really getting the fitnesse “raw” output format from the testrunner… Any ideas?

    (testrunner.exe -results TestResults.dat localhost 8085 SomeTest.SomeOtherTest)

    Thanks//J

  235. gojkoon 30 Sep 2008 at 6:41 am

    Hi Johan,

    Sorry for the late reply. I used TestRunner a while ago, and then the .NET test Runner always used the same output format. You can reformat it using the java fitnesse runner. So something like this:

    C:\services\FitNesse> dotnet2\TestRunner.exe -results c:\temp\fitnesseres.txt localhost 8888 TicketReviewTests.WinningsRecordedCorrectly

    C:\services\FitNesse> java -cp fitnesse.jar fitnesse.runner.FormattingOption c:\temp\fitnesseres.txt xml c:\temp\fitnesseres.xml localhost 8888 TicketReviewTests.WinningsRecordedCorrectly

    Maybe the functionality changed meanwhile, but I doubt it.

  236. Patrickon 30 Sep 2008 at 7:39 pm

    Hi Gojko,

    I’m currently evaluating dbfit (version of 2008.08.22) for our testing purpose. I created few tests, bundled them into test suites and been able to run them successfully. All our FitNesse files reside on a network drive but Fitnesse is run localy.

    When I use my computer, everything works fine. When I use my collegue computer and try to run any tests, I get the following error.

    System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.Exception: OCIEnvCreate failed with return code -1 but error message text was not available. at System.Data.OracleClient.OciHandle..ctor(OciHandle parentHandle, HTYPE handleType, MODE ocimode, HANDLEFLAG handleflags) at System.Data.OracleClient.OciEnvironmentHandle..ctor(MODE environmentMode, Boolean unicode) at System.Data.OracleClient.OracleInternalConnection.OpenOnLocalTransaction(String userName, String password, String serverName, Boolean integratedSecurity, Boolean unicode, Boolean omitOracleConnectionName) at System.Data.OracleClient.OracleInternalConnection..ctor(OracleConnectionString connectionOptions) at System.Data.OracleClient.OracleConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.OracleClient.OracleConnection.Open() at dbfit.AbstractDbEnvironment.Connect(String connectionString) in D:\work\dbfit\impl\dotnet\src\environment\AbstractDbEnvironment.cs:line 65 at dbfit.AbstractDbEnvironment.Connect(String dataSource, String username, String password) in D:\work\dbfit\impl\dotnet\src\environment\AbstractDbEnvironment.cs:line 59 at dbfit.DatabaseTest.Connect(String dataSource, String username, String password) in D:\work\dbfit\impl\dotnet\src\DatabaseTest.cs:line 29 — End of inner exception stack trace — at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at fitlibrary.Method.Invoke(Object[] theParameters) at fitlibrary.Method.Invoke(Fixture theFixture, IEnumerable theCells) at fitlibrary.FlowFixtureBase.ExecuteMethod(Method theMethod, CellRange theCells) at fitlibrary.FlowFixtureBase.ProcessFlowRow(Parse theCurrentRow)

    Any ideas?

    Patrick

  237. gojkoon 30 Sep 2008 at 7:44 pm

    Hi Patrick,

    there seems to be an OCI (oracle client) problem in your colleague’s computer. check if the oracle client is properly installed and set up there. possibly try to connect to the target database from your colleague’s computer using sqlplus and ping it with tnsping to troubleshoot errors.

  238. Patrickon 01 Oct 2008 at 3:19 pm

    Gojko,

    Thanks for the quick reply.

    My collegue’s computer has the same Oracle client as my computer (and we are both able to connect to the target Oracle database using SQL*Plus, TOAD, Oracle Forms, SAS,…) So I guess the problem is something else.

    This brings up another issue; testers might not necessairly have an Oracle client installed on their computers. If that’s the case, do I understand that our only option is to use the Java Test Runner? (I created a test that uses the java test runner and it works fine on both computers.)

    Patrick

  239. gojkoon 01 Oct 2008 at 6:50 pm

    The problem might be with privileges/paths to the MS Oracle ADO.NET driver, so I would suggest checking that as well (or creating a simple example that uses System.Data.Oracle client to connect to the database from his machine). Regarding the requirement for the OCI client — MS Oracle ADO.NET driver requires that. You have two options to lift that: one is to use the java test runner if you can; another is to have a centralised computer for QA to run the tests, and then have testers access that fitnesse remotely using a browser.

  240. Stephenon 07 Oct 2008 at 2:53 pm

    Gojko,

    I’ve had some problems creating expected results that number in the 500 to 1000 rows. When I try to save the results IE works for a while then it will give me an error and my results aren’t all saved. Then I can’t open the test anymore, unless I reduce the number of cases I’ve created. Is there a way around the limitations.

    Thanks
    Stephen

  241. gojkoon 07 Oct 2008 at 4:49 pm

    Hi Stephen,

    You can increase the amount of memory available to FitNesse in the start.bat/sh. Google for -Xmx java option.

  242. Gokulon 12 Oct 2008 at 7:22 pm

    Hi Gojko,

    How to include a new option in properties? Consider i want to create a new option called as “Report”, which should have the report of the test executed. The report can be in html format itself or pdf format. And it has to be stored in some destination every time this “Report” button is clicked. Please help me out with this. Thanks in advance.

  243. gojkoon 12 Oct 2008 at 7:29 pm

    Hi Gokul,

    you’ll have to change fitnesse code to do that. not sure exactly how you should do that, but try to get some information from objectmentor or on the fitnesse mailing list.

  244. Gokulon 12 Oct 2008 at 7:35 pm

    Hey Gojko,

    Thanks for the swift response. Oh what is that objectmentor and mailing list? where do i find those? Also i need info about test suites please.

  245. gojkoon 13 Oct 2008 at 11:51 am

    ObjectMentor (http://www.objectmentor.com) are the guys who built fitnesse. Mailing list is fitnesse on yahoo groups. Test suites for DbFit are also managed by FitNesse.

  246. xtremeRaceron 13 Oct 2008 at 10:52 pm

    My last reply vanished when I hit ‘Submit Comment’… 8^(

    I am having problems getting dbFit to work with .Net ans SqlServer.

    I figure it can’t be a major issue because select statements and tests work fine.

    1) Create and drop statements APPEAR to work but the tables are never created or dropped.

    2) Stored procedures, Inserts and updates generate an error message:

    System.Data.SqlClient.SqlException: Incorrect syntax near the keyword ‘precision’.

    !|Execute Procedure|CalcLength_P|
    |name|str length?|
    |mika|4|
    |paradajz|8|

    The stored procedure works fine thorugh SQL Sever Management Studio.

    Any ideas?

  247. gojkoon 13 Oct 2008 at 11:10 pm

    Hi,

    which version of SQL Server are you using? can you send me the whole page (with set-up and tear-down parts) to gojko -at- gojko.com

  248. xtremeRaceron 14 Oct 2008 at 4:43 pm

    We are using SQL Server 2000 in the development environment. If it makes a difference, our QA and production environment use SQL Server 2005.

    I sent the page code to you in an email. Thank you for the help!

  249. gojkoon 14 Oct 2008 at 10:22 pm

    Use SqlServer2000Test instead of SqlServerTest for 2000.

  250. Gokulon 15 Oct 2008 at 3:36 pm

    Hey Gojko,

    I tried running “folderrunner” as per the syntax given.

    I executed

    “java -cp fitlibraryRunner.jar fitlibrary.runner.FolderRunnerUI c:\tool\dbfit-complete-20080310\FitNesseRoot\HelloIndia c:\tool\dbfit-complete-20080310\FitNesseRoot\results”

    This is the error msg which i got:

    java -cp fitlibraryRunner.jar fitlibrary.runner.FolderRunnerUI c:\tool\dbfit-complete-20080310\FitNesseRoot\HelloIndia c:\tool\dbfit-complete-20080310

    \FitNesseRoot\results

    Exception in thread “main” java.lang.NoClassDefFoundError: fitlibrary/runner/Fol
    derRunnerUI
    Caused by: java.lang.ClassNotFoundException: fitlibrary.runner.FolderRunnerUI
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    Can you please let me know where i am going wrong?

  251. gojkoon 15 Oct 2008 at 9:12 pm

    Hi Gokul,

    absolutely no idea. I’ve never used fitlibrary folder runner. try to ask on the fitnesse mailing list, maybe someone will have a better idea.

  252. Matthewon 20 Oct 2008 at 10:33 am

    Hello Gojko,

    I am having a little trouble using dbfit as part of a larger fixture structure.

    I want to test a legacy system that uses a database by injecting some test data into said DB, running the system batch processes then comparing the data in the DB with what I expect it to be.

    Now using Fit tables I was thinking the only possible way to model this test system was to use a workflow fixture, the doFixture, and have it return a DatabaseTest fixture whenever I want to processes SQL requests.

    However when I expect say some SQL query to be coloured by fit/fitnesse the tables and all the cells in them are greyed out and counted as ignored. Is this because DatabaseTest is infact based on the doFixture itself and the original fixture code was never designed to allow workflows to create others?

    Matthew

  253. gojkoon 20 Oct 2008 at 10:43 am

    Hi Matthew,

    for that, you should be using the standalone mode. DatabaseTest is designed to control the page. See http://fitnesse.info/dbfit:modes for more information

  254. Matthewon 20 Oct 2008 at 11:50 am

    Fantastic. Thanks.

  255. Matthewon 20 Oct 2008 at 12:29 pm

    Hello Gojko,

    I have a little problem when running dbfit in standalone mode. I receive this exception in the table that initialises the connection in the DatabaseEnvironment fixture.

    “Missing method: public TypeOfResult dbfitDotFixtureDotDatabaseEnvironment(Type1 arg1) { } in class dbfit.fixture.DatabaseEnvironment”

    I dont quite know what this relates to, but I don’t really want to have to modify third party code.

    Matthew

  256. Matthewon 20 Oct 2008 at 1:14 pm

    PS: In addition, if those method sigs are added, the code in the doTables method overidden by DatabaseEnvironment is never executed, do I have an incompatable version of dbfit with my current version of Fitnesse?

    I am using dbfit 1.1 and fitnesse release 20080812.

  257. gojkoon 20 Oct 2008 at 1:41 pm

    Matthew,

    the problem is caused by packaging an incompatible version of fitlibrary with fitnesse. I complained about this on the mailing list but nobody from ObjectMentor seems to be interested in fixing it. You should not be required to add those methods to plain fit fixtures, only to fitlibrary stuff. DatabaseEnvironment doTable should be executed, not doTables.

  258. Matthewon 20 Oct 2008 at 1:55 pm

    Apologies, I did mean to say “doTable” not “doTables”. Having added instrumentation code to DatabaseEnvironment it seems that method is never run and the default environment never instantiated.

    !|dbfit.fixture.DatabaseEnvironment|informix|
    |connect using file|infrmxCon.txt|

    This is the first line of my fitnesse test page.

  259. Matthewon 20 Oct 2008 at 2:22 pm

    I seem to have fixed the problem by adding an import statement to the page.

    !|Import|
    |dbfit.fixture|

    Have you any idea what might have been causing the problem?

  260. gojkoon 20 Oct 2008 at 7:27 pm

    Hi Matthew,

    when import is the first table on the page, then the normal fit page processing is used. when DatabaseEnvironment is the first table on the page, fitlibrary kicks in and since an incompatible version of FitLibrary is packaged with the latest fitnesse release, we run into problems.

  261. Choipdon 28 Oct 2008 at 9:41 am

    I am trying to use dbfit and fitserver(c++).
    each pages with dbfit or fitserver is testing well, but i couldn’t run the suite. Gojko, do you have any idea to run with these two difference architectures mixed?

    Thank you for listen to me.

  262. gojkoon 28 Oct 2008 at 1:25 pm

    Hi,
    I’m really not sure how c++ fitserver would support dbfit. .NET and Java are supported, C++ is not out of the box. I guess you would need to rewrite dbfit to run under c++.

  263. Timon 05 Nov 2008 at 3:48 pm

    Gojko,

    Is it possible to pass the table name of a query as a parameter?
    Example: SELECT 1 AS X FROM @tablename

  264. gojkoon 05 Nov 2008 at 3:50 pm

    if you can do that directly in the database, you can do it with dbfit as well. dbfit just passes queries to the db. if this is not possible in the db, you might use markup variables to parameterise queries (but this is then not dynamic in run-time), or create your own fixture that creates the query string dynamically.

  265. Pete Johnsonon 10 Nov 2008 at 4:16 pm

    Hi Gojko
    We’ve been having a great time at Halcrow Rail MIS with Fitnesse and DbFit and have come up with some productive ways to test our ETL code and SQL Server stored procedures. We’ve become huge fans.

    One question: we’ve been having an issue with SQL timeouts while running stored procedures on SQL Server 2005 using the Query fixture. Is there a way we can amend the SQL command timeout of DBFit? We’ve tried adding a “Connection Timeout” to our connect strings but this has no effect.

    Thanks for any help.

  266. gojkoon 11 Nov 2008 at 12:10 pm

    Hi Pete,

    not sure, how would you do it if it was not going through DbFit? would you use the connection string or change the way that the call is executed?

  267. Antonon 11 Nov 2008 at 1:32 pm

    I can’t connect to my Derby db from Fitnesse.

    I use the following connection string
    !|dbfit.DerbyTest|
    !|Connect|jdbc:derby://localhost:1527/testdbfit;|

    I’ve started the derby networkServer.

    When I run my Fitnesse test I get the error below
    java.lang.Error: Cannot register SQL driver org.apache.derby.jdbc.ClientDriver
    ……………..

  268. gojkoon 11 Nov 2008 at 3:29 pm

    Hi,

    is the derby java driver jar in your test run class path?

  269. Antonon 12 Nov 2008 at 9:38 am

    Thanks Gojko, I copied the Derby driver jar to my Fitnesse installation and it solved the problem.

  270. Timon 13 Nov 2008 at 4:43 pm

    Hi, gojko,

    In SQL Server stored procedures, you indicated that you cannot validate the results of a RETURN call because the type is not known. In SQL Server, the return type of a stored procedure call is always an integer. Does this “rule” make it possible to treat the stored procedure call like a function so we can validate the return value?

    Great work on a great tool, btw!

    Tim

  271. Timon 13 Nov 2008 at 8:35 pm

    Is there a possibility of a config item that would define the special text to denote a check for a zero length string (or all spaces)? We often want to validate that an OUTPUT parameter has been set to a blank string and Fitnesse itself doesn’t allow this since a blank validation implies “no check.” I’m thinking something along the same lines as the special handling of “null.” It doesn’t necessarily have to be configurable, though this might address a future complaint that someone’s stored proc is actually returning the special text used to denote an empty string.

    Thanks again for a very cool tool.

  272. Stephenon 13 Nov 2008 at 9:07 pm

    Hello,

    I just got a new machine. Loaded java (it has 5 and 6) and made sure the Path is correct (c:\Program Files\Java\jre1.5.0_12;c:\Program Files\Java\jre1.6.0_7). But I keep getting the following error:

    C:\Fitnesse\DbFit>java -cp lib\fitnesse.jar fitnesse.FitNesse -p 8085 -e 0 -o

    Exception in thread “main” java.lang.UnsupportedClassVersionError: fitnesse/FitN
    esse (Unsupported major.minor version 49.0)
    at java.lang.ClassLoader.defineClass0(Native Method)

    My old machine still works just fine. I did download the newest release.

    Thanks for the help.

  273. gojkoon 14 Nov 2008 at 11:34 am

    Stephen, try running it with java6 instead of java 5

  274. gojkoon 14 Nov 2008 at 11:44 am

    Tim,

    see fixed length string parsing on the query page, this might help check empty strings. regarding sql server stored procedures, I’m still unsure about how this might work. Do you suggest assigning a “return” stored procedure argument to every stored procedure?

  275. Timon 14 Nov 2008 at 1:38 pm

    gojko, I did try out the fixed length query capability earlier (and retried it today just to be sure):

    |set option|fixed length string parsing|true|
    !|Execute Procedure|usp_ValidateCartonLoadingDestinationForStart|
    |Build Lane|One Carton At A Time|Is On|ReturnLog?|
    |null|Y|N|100,@BuildLane,NULL|
    |BadDivert|Y|N|Invalid Divert. Refer Store Map Table for valid diverts|
    |BadDivert|Y|Y|’ ‘|

    @ReturnLog is declared as varchar(200) and is returning a zero-length string. I’ve tried ”, ‘ ‘, ‘(200 spaces)’ and all produce a failure when comparing. I don’t know if this is relevant, but the error message shows the quoted string (including the quotes) in the expected field, and just the word “actual” in the other field. Also, once you go to one space between the quotes, the error message shows one space between the quotes, no matter how many spaces you put between the quotes.

    I messed around with the stored proc, returning an explicit ‘ ‘, ‘Hi ‘, ‘Hi’ with corresponding quoted validation values in dbfit. None of them matched, so, I’m thinking that the “fixed length string parsing” setting isn’t actually affecting the comparison logic for stored procs (?). I pasted the line for “Set option” so I don’t think it is horked over. Is there anything obviously wrong with my approach?

  276. Timon 14 Nov 2008 at 1:43 pm

    gojko, I think I now understand the issue with a return value for a stored proc. You’re implying that a change like this would break every existing check since the line would now *require* a reference to |?|, right? Is it at all reasonable to think that you could make the presence of the |?| optional? If it is there, it compares against the return value and if not, treat the stored proc as if it had no return value.

    Sorry for just asking the question. I really should do a little code spelunking…

  277. Linhon 14 Nov 2008 at 7:28 pm

    gojko, is there a way to escape the ‘|’ character in DbFit. I’m have a need to use this character in my query.
    Thanks.

  278. gojkoon 15 Nov 2008 at 2:30 pm

    Linh,

    use !- and -! to escape characters in fitnesse (and dbfit). you can find more about that in the project docs

  279. ekkison 16 Nov 2008 at 2:26 am

    hei gojko,

    I found your software recently through a SQL Server Central article:

    http://www.sqlservercentral.com/articles/Testing/64636/

    and in attempting to follow it I’m running into trouble. I’m running against a SQL Server 2000 box and have the following code:

    !|Insert|DBFitTest|
    |EmpName|FavoriteColor|
    |Ian Curtis|NULL|
    |Peter Hook|Grey|

    to which I get:

    System.Data.SqlClient.SqlException: Incorrect syntax near the keyword ‘precision’.
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

    I do have connectivity to the database because I have queries that return values (including one that indicates the presence of the table)… and I also have the most recent (as of a couple of days ago) version of the software… I’ve looked at docs and the syntax seems right… what am I running into?

    1k thx – e

  280. gojkoon 16 Nov 2008 at 12:00 pm

    Ekkis,
    use SqlServer2000Test instead of SQLServerTest when running on 2000. that will give you most of the functionality with legacy meta-data extraction. SQLServerTest only works with 2005 onwards

  281. Davidon 17 Nov 2008 at 1:56 pm

    Does DBFit support SQL 2008? I am getting the following error when I run the following query SELECT CONVERT(BIT, ISNUMERIC(‘12′)) AS ‘result’:
    fitlibrary.exception.InvalidMethodException: Missing method ‘query’ with 5 argument(s).
    at fitlibrary.Method.FindFirst(Object theTarget, IdentifierName theIdentifierName, Int32 theParameterCount)
    at fitlibrary.FlowFixtureBase.FindMethod(CellRange theCells)
    at fitlibrary.FlowFixtureBase.FindRowMethod(Parse theRow)
    at fitlibrary.FlowFixtureBase.ProcessFlowRow(Parse theCurrentRow)

  282. gojkoon 17 Nov 2008 at 2:41 pm

    David,

    the error suggests that your table format is wrong (5 arguments for the query method). Can you send me the fitnesse page that you are trying to use?

  283. ekkison 18 Nov 2008 at 11:30 pm

    thank you (sorry for cluttering the board)! your product is AWESOME.

  284. Billon 24 Nov 2008 at 7:10 pm

    Gojko,

    I am having the same sort of timeouts as Pete Johnson above (http://gojko.net/fitnesse/dbfit/#comment-36523). In your reply to him (http://gojko.net/fitnesse/dbfit/#comment-36534), you asked “How would you do it if it was not going through DbFit? would you use the connection string or change the way that the call is executed?”

    In C#, I would do it by setting the CommandTimeout property of the Command object. As far as I know, CommandTimeout cannot be set through the connection string. (ConnectionTimeout can be set, but that only governs how long it will wait to make the initial connection, not how long each command will be given.)

    –Bill

  285. gojkoon 24 Nov 2008 at 10:02 pm

    Bill,

    thanks for the info, I’ll add that option to dbfit 1.2. I’m a bit behind on dbfit features because my upcoming book is taking all my time, but I promise to get this done as soon as the book is out.

  286. Linhon 02 Dec 2008 at 6:08 pm

    Gojko,
    To make use of DbFit in my project I have added Postgres support to the Java version. If it is possible, may I send my code to you for an expert review. I’m sure there are places where things may be done a little more optimally.
    Thanks.

    -Linh

  287. gojkoon 04 Dec 2008 at 3:43 pm

    Linh,

    that would be great. Please send it to gojko@gojko.com

  288. Roberton 10 Dec 2008 at 5:59 pm

    Gojko,

    Does DbFit support PostgreSQL?

    Regards,
    Robert

  289. gojkoon 11 Dec 2008 at 5:43 am

    Robert,

    PostgreSQL support is in development. As soon as i finish my book i’ll be back on polishing dbfit, so I expect the real version to be released in the next month or so.

Trackback URI |