question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support DataSourceAttribute in .Net Core.

See original GitHub issue

Description

We have following code

[TestMethod]
[DeploymentItem("MyTests.Configuration.xml")]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\MyTests.Configuration.xml", "MyTestCase", DataAccessMethod.Sequential)]
public void GetFiles_OnRootDirectory_CallsApiCorrectly()
{
    var foo = TestContext.DataRow["MyFooData"]);
}

with following xml file

<?xml version="1.0" encoding="utf-8" ?>
<Rows>
  <MyTestCase>
    <MyFooData>true</MyFooData>
  </MyTestCase>
  <MyTestCase>
    <MyFooData>false</MyFooData>
  </MyTestCase>

  <OtherTestCase>
    <MyFooData>false</MyFooData>
  </OtherTestCase>
</Rows>

Is TestContext.DataRow expected to come to MsTest v2, or is it any other way to do the same thing?

Steps to reproduce

  1. Install .NET Core 2.0.0-preview2-006497
  2. Target the test project to ,NET Core 2.0
  3. Use MSTest.TestAdapter version 1.2.0-beta
  4. Try to build

Expected behavior

The compile past

Actual behavior

I get following build error

error CS1061: ‘TestContext’ does not contain a definition for ‘DataRow’ and no extension method ‘DataRow’ accepting a first argument of type ‘TestContext’ could be found (are you missing a using directive or an assembly reference?)

Environment

.NET Core 2.0.0-preview2-006497 Visual Studio 15.3.0 preview 7.0 Windows 10

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:16
  • Comments:47 (11 by maintainers)

github_iconTop GitHub Comments

7reactions
cilerlercommented, Oct 24, 2018

@rhyous

  1. The very basic example I provided above is for demonstration purpose only to let others see how easy it is to implement it. I literally didn’t expect no one to use it for production.
  2. As you already mentioned above you have compiler directives which means it should not break your code base. (you can’t expect everyone having a need to support multiple frameworks, many developers are developing fresh new projects and the method I presented may help them to continue with the latest stuff)
  3. The situation is pretty simple writing your own parser VS waiting for years to get it from Microsoft. (Well, I usually prefer to write my own at this point in order to be able to use the latest stuff)

Therefore please take it into the consideration that it could be very easy workaround where things are not complicated as it in your projects.

7reactions
rhyouscommented, Apr 17, 2018

Trying to move my Unit Tests to .NET Core 2.0. Of course, I have many row tests. I’ll have a look at Dynamic data. But the problem is all the existing row tests use DataSourceAttribute.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - What`s .Net core alternative of DataSource attribute for ...
Info: .NET Core does not support the DataSource attribute. If you try to access test data in this way in a .NET Core...
Read more >
Create Data-Driven Unit Tests - Visual Studio (Windows)
Learn unit test concepts in C# and .NET through an interactive experience building a sample solution step-by-step using dotnet test and MSTest.
Read more >
Work with data in ASP.NET Core Apps
ASP.NET Core supports various data access options, including Entity Framework Core (and Entity Framework 6 as well), and can work with any .NET ......
Read more >
How to bind report to an object data source in .NET Core ...
I am working on a project in .NET Core. It is a web api and I am trying to use XtraReport, which since...
Read more >
Problem with assigning DataSource for XtraReport in .Net ...
Hi, I have migrated Report from .Net Framework to .Net Core, I followed this https://docs.devexpress.com/XtraReports/401268/net-5-report- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found