简体   繁体   中英

MSTest Data source - pass on a custom object collection

I am creating a selenium framework using 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.

Given this scenario, could any one please help me as how to pass on this list data to the [testmethod] function.

I googled it and I found we can use [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).

It is possible with Nunit to achieve this using TestCaseSource

There is also a NuGet package to extend MSTest to include this functionality

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM