Error running .Net and SQL tests in dbfit

296 Views Asked by At

I have a simple C# Column fixture class which independently tests fine. I have a sql server table which again, independently tests fine. If I test both, testing the SQL table first, again all is OK. However if I test the C# first, then the SQL test fails 'Type 'Connect' not found in assemblies'

So this works fine...

!define COMMAND_PATTERN {%m -r fitnesse.fitserver.FitServer %p}
!define TEST_RUNNER {fitsharp\Runner.exe}
!define PATH_SEPARATOR {;}

!path fitsharp/fit.dll
!path fitsharp/dbfit.sqlserver.dll

!|dbfit.SqlServerTest|
!|Connect|Data Source=localhost;integrated security=SSPI;Initial     Catalog=Test2|
!|Query| select Colour from dbo.Colour|
|Colour|
|yellow-orange|

!path Fixtures.dll

!|Fixtures.SampleDo|
|firstPart|secondPart|together?|totalLength?|
|Hello|World|Hello, World|10|
|Houston|We Have a Problem|Houston, We Have a Problem|24|

... but this fails by simply moving the Fixtures.dll test ...

!define COMMAND_PATTERN {%m -r fitnesse.fitserver.FitServer %p}
!define TEST_RUNNER {fitsharp\Runner.exe}
!define PATH_SEPARATOR {;}

!path Fixtures.dll

!|Fixtures.SampleDo|
|firstPart|secondPart|together?|totalLength?|
|Hello|World|Hello, World|10|
|Houston|We Have a Problem|Houston, We Have a Problem|24|

!path fitsharp/fit.dll
!path fitsharp/dbfit.sqlserver.dll

!|dbfit.SqlServerTest|
!|Connect|Data Source=localhost;integrated security=SSPI;Initial     Catalog=Test2|
!|Query| select Colour from dbo.Colour|
|Colour|
|yellow-orange|
1

There are 1 best solutions below

4
On BEST ANSWER

Update: The original solution described below does not work for DbFit. Here is a workaround:

In your fixture SampleDo, you can include the following to let SqlServerTest handle the rest of the tables in the test:

public override bool IsVisible { get { return false; } }

Original answer:

When using DbFit, the table

!|dbfit.SqlServerTest|

is usually the first table in the test so it becomes the "System Under Test" and subsequent tables like

!|Connect|Data Source=localhost;integrated security=SSPI;Initial     Catalog=Test2|

are interpreted as methods to be executed on SqlServerTest.

If it is not the first table, something else will be the "System Under Test", in your case, SampleDo, and FitNesse will look for a method Connect on SampleDo. To make SqlServerTest the "System Under Test" part way through the test, use the with keyword:

!|with|new|dbfit.SqlServerTest|