[英]SQL data table as test data in Unit Tests
I have tried unit testing with test data from excel sheet and it worked fine (after following the instructions from MSDN dosuments). 我已经尝试使用excel表格中的测试数据进行单元测试,并且效果很好(遵循了MSDN文档的说明)。 However now I would like to take the test data directly from data base, can anyone please tell me the steps to follow as I was unable to find related document in the Website.
但是,现在我想直接从数据库中获取测试数据,由于我无法在网站上找到相关文档,因此任何人都可以告诉我要执行的步骤。
I am using Microsoft Visual Studio 2012 and Microsoft SQL Server Management Studio. 我正在使用Microsoft Visual Studio 2012和Microsoft SQL Server Management Studio。 Is there anything else also I need in order to acheive the task?
我还需要其他什么来完成任务吗?
Regards, 问候,
SJ SJ
I am using Microsoft Unit Test Framework. 我正在使用Microsoft单元测试框架。 In this we can add a data source for unit testing.
在此,我们可以添加用于单元测试的数据源。 I added the following data source for Excel sheet:
我为Excel工作表添加了以下数据源:
<connectionStrings>
<add name="MyExcelConn"
connectionString="Dsn=Excel Files;dbq=.\\CoreTestData.xlsx;defaultdir=.; driverid=790;maxbuffersize=2048;pagetimeout=5"
providerName="System.Data.Odbc" />
</connectionStrings>
<microsoft.visualstudio.testtools>
<dataSources>
<add name="MyExcelDataSource"
connectionString="MyExcelConn"
dataTableName="Sheet1$"
dataAccessMethod="Sequential"/>
</dataSources>
</microsoft.visualstudio.testtools>
Now wondering if we can somehow do the same with data table. 现在想知道我们是否可以对数据表执行相同的操作。 Reference : http://msdn.microsoft.com/en-us/library/ms182527.aspx
参考: http : //msdn.microsoft.com/zh-cn/library/ms182527.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.