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.

Provide a way to opt-out of discovery time expanding of ITestDataSource tests

See original GitHub issue

Description

We recently changed how ITestDataSource tests are discovered. We need to provide a way to opt-out from this behavior.

Proposal

  • Ability to opt-out assembly, type or test case level by using an attribute.
  • Ability to opt-out using a command-line parameter or .runsettings setting.

Steps to reproduce

protected static readonly Guid _subscriptionId = Guid.NewGuid();

[DynamicData(nameof(GetData), DynamicDataSourceType.Method)]
[DataTestMethod]
public void MyTest1(Guid subscriptionId)
{
}

private static IEnumerable<object[]> GetData()
{
    yield return new object[]
    {
        _subscriptionId
    };
}

Expected behavior

Discovered Tests: 
 - MyTest1

Actual behavior

Discovered Tests:
 - MyTest1 (e6a883d7-03b5-4231-a06f-99e5847eb9b0)

AB#1353020

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
patest-devcommented, Jul 24, 2021

The opt-out is very(!!) much needed and all this new discovery time behavior should actually be an opt-in. How could all of these breaking changes be introduced on a minor version??

Even a DynamicData test as simple as this one, is now only being executed 2-times and the null case is simply lost

private static IEnumerable<object[]> GetData()
{
    List<object[]> ret = new List<object[]>()
    {
        new object[] { null },
        new object[] { "" },
        new object[] { "a" },
    };
    return ret;
}

[TestMethod]
[DynamicData(nameof(GetData), DynamicDataSourceType.Method)]
public void StringTest(string test)
{
    Console.WriteLine(test);
}
3reactions
ttorkelsoncommented, Apr 27, 2022

The opt-out is very(!!) much needed and all this new discovery time behavior should actually be an opt-in. How could all of these breaking changes be introduced on a minor version??

Even a DynamicData test as simple as this one, is now only being executed 2-times and the null case is simply lost

private static IEnumerable<object[]> GetData()
{
    List<object[]> ret = new List<object[]>()
    {
        new object[] { null },
        new object[] { "" },
        new object[] { "a" },
    };
    return ret;
}

[TestMethod]
[DynamicData(nameof(GetData), DynamicDataSourceType.Method)]
public void StringTest(string test)
{
    Console.WriteLine(test);
}

I totally agree that this should be an opt-in rather than an opt-out. These changes caused quite a bit of headache in my org

Read more comments on GitHub >

github_iconTop Results From Across the Web

Test data "disappearing" when using MSTest DynamicData
1 Answer. This is happening due to an undocumented breaking change in MsTest 2.2. 4 which changes the default behavior for discovering ......
Read more >
Visual Studio Test Explorer FAQ
How can I discover these tests? Build your project to run assembly-based discovery. Real-time test discovery is source-based test discovery.
Read more >
Unit testing - Data-driven tests - DataMiner Dojo
Data-driven testing is about providing a unit test with data that is then used during the execution of the unit test.
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