1

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|
Tirinoarim
  • 624
  • 7
  • 14

1 Answers1

1

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|
Mike Stockdale
  • 5,256
  • 3
  • 29
  • 33
  • Its certainly got me closer but now I'm getting a different error.. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object. at fitSharp.Fit.Engine.CellProcessorExtension.Get[V](CellProcessor processor) at dbfit.DatabaseTest.Query(String query) --- End of inner exception stack trace --- at fitSharp.Machine.Model.TypedValue.ThrowExceptionIfNotValid() at fitSharp.Fit.Operators.InterpretFlow.ProcessFlowRow(Tree`1 table, Int32 rowNumber) – Tirinoarim Feb 09 '17 at 16:44
  • I've updated the answer with a workaround as there is a bug in DbFit that causes the error you are seeing. – Mike Stockdale Feb 09 '17 at 18:51
  • Thanks again for the quick reply Mike. I've added the override as suggested (and removed the "with|new") but I'm afraid I'm now back to the original "Connect not found in assemblies" error :( – Tirinoarim Feb 10 '17 at 09:50
  • You sir, are an absolute star!!! :D Thank you for your time, patience and expertise. – Tirinoarim Feb 11 '17 at 20:34