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.

Inline DataRow is not available on TestContext.DataRow for Inline [DataTestMethod]

See original GitHub issue

Description

Describe the issue you’ve observed I have a test:

        [TestMethod]
        [TestCategory("VisualParity")]
        [DataTestMethod]
        [DataRow(TestScreen.Large, LocaleDirection.RTL, Ring.WorldWide)]
        public void HomeConsumer_Hero_Screenshot(int screenWidth, string direction, string ring)
        {
            SetupTest(screenWidth, direction, ring);

            // in some later code, where TestContext is passed in...
            var screenshotName = TestContext.TestName + "_" + TestContext.DataRow.ItemArray[0];
            // ...
        }

DataRow is null

Steps to reproduce

What steps can reproduce the defect? Please share the setup, sample project, target platform (desktop, core, uap)

Nothing special besides above test. It is a desktop net45 project

Expected behavior

Share the expected output

I would expect TestContext.DataRow to be properly populated

Actual behavior

What is the behavior observed?

TestContext.DataRow is null

Environment

Please share additional details about the test environment. Operating system, Build version of vstest.console, Package version of MSTest framework and adapter

VS2017 15.4 Windows 10 Latest MSTest 1.1.18

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
SimonCroppcommented, Dec 14, 2019

can this be re-opened. it would be really helpful to get access to the test parameters via the TestContext

1reaction
yuzhangcsrcommented, Nov 9, 2018

@AbhitejJohn , is there any other way/workaround to get the data other than from Testmethod parameters when I am using DataRow, I am asking is because my test framework is using [TestCleanup] method to generate test report via reading TestContext to get test name, status etc. And now the datarow in TestContext is null by design if using [DataRow]

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inline DataRow is not available on TestContext. ...
I have a test: [TestMethod] [TestCategory("VisualParity")] [DataTestMethod] [DataRow(TestScreen.Large, LocaleDirection.RTL, Ring.
Read more >
'TestContext' does not contain a definition for 'DataRow'
DataRow where TextContext is a class which has no static property named DataRow so in order to use it you need to create...
Read more >
Create Data-Driven Unit Tests - Visual Studio (Windows)
A data-driven unit test can use any of the following kind: inline data using the DataRow attribute; member data using the DynamicData attribute ......
Read more >
Unit testing - Data-driven tests - DataMiner Dojo
The DataRow attribute allows you to define inline data for a test method. Consider the following example where a unit test verifies whether ......
Read more >
Data-Driven Testing with Visual Studio
Every developer needs to test their own code or have it tested by someone else. Many developers aren't great at testing their own...
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