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.

Timed out datarow affects subsequent datarows

See original GitHub issue

Description

When executing a test with multiple datarows, and one datarow times out, all subsequent datarows are aborted and marked failed.

Steps to reproduce

Runt the following test:

    [TestClass]
    public class UnitTest1
    {
        [DataTestMethod]
        [DataRow(1)]
        [DataRow(2)]
        [DataRow(3)]
        [DataRow(2000)]
        [DataRow(4)]
        [DataRow(5)]
        [Timeout(500)]
        public async Task TestDataRowTimeout(int delay)
        {
            await Task.Delay(delay);
        }
    }

Expected behavior

Only datarow with value 2000 times out. However row 4 and 5 are aborted with message Test 'TestDataRowTimeout' execution has been aborted. The timeout doesn’t apply to the combined time for all rows - that can be confirmed by setting the first few rows to be very close to 500, and added up exeeding the timeout value. If the combined time spent mattered, it would time out before making it to the slow row.

Actual behavior

all rows after the timed out row are aborted. image

Environment

VS2019.7. .NET Core 3.1. using latest packages.

.csproj used:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
    <PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
  </ItemGroup>

</Project>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
Haploiscommented, Jun 23, 2021

@dotMorten, this should be fixed with out latest release. Please use 16.10.0 version of Microsoft.NET.Test.Sdk and the latest preview of MSTest; and let us know if you still have this problem.

0reactions
nohwndcommented, Jun 24, 2021

@dotMorten

I’m confused about the above response. It seems to deal with how to deal with tearing down a test after a timeout, and not with the fact that each datarow isn’t run as a new test but the outcome of the previous test can affect the outcome of the following tests.

There are multiple things mixed together.

  1. MSTest (until the update you are testing), reported each testcase in the same test. The timeout applies to the test, that is to all testcases combined. If all testcases together take more time than the timeout, the timeout will be triggered.

  2. With the update each test case is reported as a single test, and will get its own timeout.

  3. BUT still, if any test times out, the timing out should trigger killing the process, which used to happen, but it seems to not happen anymore. Instead we complete a task that reports error, but the task that is running the test code still continues. It behaves the same way that NUnit is behaving. But now after the update the next test gets the chance to run, even though the timed out test is still running in the background.

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Threading.Tasks;

namespace TestProject12
{
    [TestClass]
    public class UnitTest1
    {
        [DataRow("tc1", 500)]
        [DataRow("tc2", 2000)]
        [DataRow("tc3", 3000)]
        [Timeout(1000)]
        [TestMethod]
        public async Task Test(string name, int milliseconds)
        {
            System.IO.File.AppendAllLines(@"C:\t\mstest.txt", new[] { $"{name} start" });
            await Task.Delay(milliseconds);
            System.IO.File.AppendAllLines(@"C:\t\mstest.txt", new[] { $"{name} end" });
        }
    }

    [TestClass]
    public class UnitTest2
    {
        [TestMethod]
        public async Task Test2()
        {
            await Task.Delay(3000);
        }
    }
}

Output:

tc1 start
tc1 end
tc2 start
tc3 start
tc3 end
tc2 end
tc1 start
tc1 end
tc2 start
tc3 start
tc3 end
tc2 end

Pre update: image

After update: image

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - SetAdded and SetModified can only be called on ...
By doing some research, I am able to find out the answer myself. The row state of DataTable can be changed to Unchanged...
Read more >
Updating Data Sources with DataAdapters - ADO.NET
Calling AcceptChanges on the DataSet , DataTable , or DataRow will cause all Original values for a DataRow to be overwritten with the...
Read more >
Dumb Schedules - parameter conflict and insert data row ...
I made some schedules that did allow the addition of rows to be inserted above or below, but now the option to insert...
Read more >
SSRS 2012: Errmsg 'Cannot read the next data row for ...
Hi All In SSRS 2012 I have a report that returns the error message in the question title when ran on our SSRS...
Read more >
What is the limit of records we can deal with?
If you have too many rows to get good performance, then the first things to try are using Deferred Rendering (so only the...
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