What is the replacement for TestContext.DataRow[“MyColumnName”]

前端 未结 1 932
臣服心动
臣服心动 2021-02-20 09:58

Using MSTest in a .Net Core Unit test project. I am attempting to use a csv datasource to provide the data for a test method.

Previously, I would use something like belo

相关标签:
1条回答
  • 2021-02-20 10:22

    Since moving to aspnet core, I've never been able to use the same [Datasource(...)] attribute to iterate through test data, my data-driven tests are always skipped.

    Have you considered switching to another approach with [DataTestMethod] and [DynamicData] with a custom source that reads you file ?

    Here's a good article on this :

    https://www.meziantou.net/2018/02/05/mstest-v2-data-tests

    Maybe another way would be to read the whole file at the begining of the test and then iterate through the dataset as One single unit test?

    Hope this helps.

    0 讨论(0)
提交回复
热议问题