Build/Test Issues

Long test names cause Visual Studio UI hangs with NCrunch enabled

Started by jamezor on 2,794 views

With an otherwise empty project/solution, and all default NCrunch settings, the following test experiences very poor performance with the Visual Studio UI hanging for 1 - 2 seconds per keystroke; disabling NCrunch immediately resolves the issue.

    internal class TestClass
    {
        private static IEnumerable<TestCaseData> TestCaseSource()
        {
            return Enumerable.Range(0, 10).Select(i => new TestCaseData(i).SetName(new string('*', 2000) + i.ToString()));
        }

        [TestCaseSource(nameof(TestCaseSource))]
        public void Given_a_test_case_source_with_long_test_names_When_running_NCrunch_Then_the_Visual_Studio_UI_hangs_a_lot(int i)
        {
            Assert.That(i, Is.GreaterThan(0));
        }
    }


As the test names get longer or the number of tests with long names grows the slowdown seems to get exponentially worse. We've taken to presenting a MD5 hash of the test name to NUnit/NCrunch instead of the actual long name to avoid this issue but that is not very elegant.

NCrunch 3.12.0.15, Visual Studio 2017 15.5.6, Windows 10 64bit.
Hi, thanks for sharing this.

With your sample code, I can reproduce a problem in the UI that causes NCrunch to eat up the main thread while it tries to render the long test name. This will definitely slow VS right down.

We'll take a look and see if we can get this fixed. Using a hash for the test name is a good workaround for the time being.

Post a reply

Log in to reply.