Visual Studio.net中的单元测试 [英] Unit test in Visual Studio.net
本文介绍了Visual Studio.net中的单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在项目中编写了单元测试类.在这里我得到了错误.
单元测试适配器无法连接到数据源或读取数据.有关解决此错误的详细信息,请参阅MSDN Library中的对数据驱动的单元测试进行故障排除"(http://go.microsoft.com/fwlink/?LinkId=62412).
错误详细信息:无法找到请求的.Net Framework数据提供程序.可能未安装.
I wrote Unit test class in my project. here i am getting error.
The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see "Troubleshooting Data-Driven Unit Tests" (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library.
Error details: Unable to find the requested .Net Framework Data Provider. It may not be installed.
[TestMethod()]
[DataSource("System.Data.EntityClient", "metadata=res://*/NorthModel.csdl|res://*/NorthModel.ssdl|res://*/NorthModel.msl;provider=System.Data.SqlClient;provider connection string="data source=SREEKANTH;initial catalog=Northwind;integrated security=True;multipleactiveresultsets=True;App=EntityFramework","Products", DataAccessMethod.Sequential)]
public void GetProductsTest()
{
Products prod = new Products();
prod.Productid = (int)TestContext.DataRow[0];
prod.ProductName = (string)TestContext.DataRow[1];
prod.Categoryid = (int)TestContext.DataRow[3];
prod.UnitPrice = (int)TestContext.DataRow[5];
List<Products> p = new List<Products>();
p.Add(prod);
ProductClass target = new ProductClass(); // TODO: Initialize to an appropriate value
List<Products> expected = p; // TODO: Initialize to an appropriate value
List<Products> actual;
actual = target.GetProducts();
Assert.AreEqual(expected, actual);
Assert.Inconclusive("Verify the correctness of this test method.");
}
请帮帮我.
谢谢.
please help me.
thank you.
推荐答案
在安装Visual Studio时需要安装单元测试框架.
检查此信息 [
You need the unit test framework installed when you install Visual Studio.
Check this out[^].
这篇关于Visual Studio.net中的单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文