[英]MSTest Data source - pass on a custom object collection
I am creating a selenium framework using MSTest. 我正在使用MSTest创建一个硒框架。 The data which is being used is quite complex and it is a collection of objects. 使用的数据非常复杂,并且是对象的集合。 The objects are in a List. 这些对象在列表中。
Each of the item in the list represent a test case. 列表中的每个项目都代表一个测试用例。 During the [TestInitialize] phase, I create this list. 在[TestInitialize]阶段,我创建了此列表。
Given this scenario, could any one please help me as how to pass on this list data to the [testmethod] function. 在这种情况下,任何人都可以帮助我如何将列表数据传递给[testmethod]函数。
I googled it and I found we can use [DataSource("Microsoft.VisualStudio.TestTools.DataSource")] 我用谷歌搜索,发现可以使用[DataSource(“ Microsoft.VisualStudio.TestTools.DataSource”)]
But not sure how to pass this list to the testmethod 但不确定如何将此列表传递给测试方法
Any pointers on how this can be achieved will be very helpful. 关于如何实现此目标的任何指示都将非常有帮助。
Many thanks 非常感谢
I'm pretty sure this isn't possible with MSTest, you can currently only hook up DataSource() with a connection string to a datasource (eg. sql). 我非常确定这对于MSTest是不可能的,您目前只能通过带有到数据源(例如sql)的连接字符串的DataSource()进行连接。
It is possible with Nunit to achieve this using TestCaseSource Nunit可以使用TestCaseSource实现此目的
There is also a NuGet package to extend MSTest to include this functionality 还有一个NuGet包来扩展MSTest以包括此功能
I have also read they are going to be adding this feature to MSTest, it is currently in preview and possibly only supports UWP and Desktop Apps. 我还阅读了他们将向MSTest添加此功能的信息,该功能目前处于预览状态,可能仅支持UWP和桌面应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.