简体   繁体   English

在 dbfit 中运行 .Net 和 SQL 测试时出错

[英]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.

相关问题 在 Docker 容器中运行 SQL Lite 内存单元测试时出错 - Error Running SQL Lite In-Memory Unit Tests in Docker Container 在Asp.Net Core Web应用程序(.NET Framework)4.6上运行单元测试时出错 - Error Running Unit Tests on Asp.Net Core Web Application (.NET Framework) 4.6 针对 SQL 服务器数据运行 XUnit 测试时出错 - 为 Tests.UnitTest1.Test1 上的 Tests.SqlServerDataAttribute 指定的数据发现器不存在 - Error running XUnit Test against SQL Server Data - Data discoverer specified for Tests.SqlServerDataAttribute on Tests.UnitTest1.Test1 does not exist 独立运行单元测试(.net core) - Running unit tests independently (.net core ) 在VSTS中运行xunit.net测试 - Running xunit.net tests in VSTS 在 MacOS 中对 .net 核心项目运行 NUnit 测试 - Running NUnit tests on .net core project in MacOS 运行包含在.NET Standard 1.6库中的xunit测试 - running xunit tests included in a .NET Standard 1.6 library 运行NUnit测试时的错误配置文件(TD.NET) - Wrong configuration file when running NUnit tests (TD.NET) 使用 .NET Core MSTest 运行单元测试:“未找到以下 TestContainer...” - Running unit tests with .NET Core MSTest: “The following TestContainer was not found…” 运行SpecFlow测试时Log4Net在Selenium Framework中不起作用 - Log4Net not working in Selenium Framework when Running SpecFlow Tests
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM