简体   繁体   English

MSTest数据源-传递自定义对象集合

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

相关问题 MSTest自定义测试传递消息 - MSTest custom test-pass message 使用JQuery将自定义集合对象从Controller传递到View - Pass custom collection object from Controller to View with JQuery 在C#中将数据源对象内的集合绑定到DataGridView - Binding a collection inside a data source object to a DataGridView in C# 如何将对象传递给自定义数据注释验证器 - How to pass a object to a custom Data annotation Validator 具有嵌套集合的自定义对象 - Custom object with nested collection 自定义对象集合到SqlDataReader - custom Object collection to SqlDataReader 如何使用 mstest 或 nunit 将 DataTable 用作我的测试用例的数据源? - How can i use DataTable as a data source for my test case using mstest or nunit? 我如何使用linq对集合对象执行WHERE操作(使用Netflix数据源) - How do I use linq to do a WHERE against a collection object (using Netflix data source) 当新测试项目的测试被引入解决方案时,MSTest单元测试适配器无法连接到数据源 - MSTest Unit Test Adapter Failing to Connect to Data Source When Tests From New Test Project Are Introduced to Solution 如何将自定义数据传递到log4net.Core.LoggingEvent对象? - How to pass custom data to the log4net.Core.LoggingEvent object?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM