[英]Error running .Net and SQL tests in dbfit
I have a simple C# Column fixture class which independently tests fine.我有一个简单的 C# Column 夹具类,它独立测试得很好。 I have a sql server table which again, independently tests fine.
我有一个 sql server 表,它再次独立测试得很好。 If I test both, testing the SQL table first, again all is OK.
如果我同时测试两者,首先测试 SQL 表,那么一切都还可以。 However if I test the C# first, then the SQL test fails 'Type 'Connect' not found in assemblies'
但是,如果我先测试 C#,则 SQL 测试失败“在程序集中找不到类型‘连接’”
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 ... ...但是这通过简单地移动 Fixtures.dll 测试而失败......
!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|
Update: The original solution described below does not work for DbFit.更新:下面描述的原始解决方案不适用于 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:在您的
SampleDo
,您可以包含以下内容,让SqlServerTest
处理测试中的其余表:
public override bool IsVisible { get { return false; } }
Original answer:原答案:
When using DbFit, the table使用 DbFit 时,表
!|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
.被解释为要在
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
.如果它不是第一个表,则其他内容将是“被测系统”,在您的情况下,
SampleDo
和 FitNesse 将在SampleDo
上查找方法Connect
。 To make SqlServerTest
the "System Under Test" part way through the test, use the with keyword:要在测试过程中使
SqlServerTest
成为“被测系统”,请使用 with 关键字:
!|with|new|dbfit.SqlServerTest|
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.