2 Replies - 663 Views - Last Post: 23 February 2016 - 12:18 AM Rate Topic: -----

#1 cfoley   User is offline

  • Cabbage
  • member icon

Reputation: 2410
  • View blog
  • Posts: 5,050
  • Joined: 11-December 07

Slow tests in Visual Studio

Posted 22 February 2016 - 01:52 PM

Is it normal for tests to take 5 seconds to launch in Visual Studio?

I'm using the NUnit 2 test runner.

Here is my code. This is the only cs file in the project:

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

namespace UnitTestProject1
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            Assert.AreEqual(1, 1);
        }
    }
}



And here is the output. The results say the test took 10 ms so I presume the rest of the time is starting up and detecting test methods.

------ Run test started ------
NUnit VS Adapter 2.0.0.0 executing tests is started
Loading tests from C:\<snip>\UnitTestProject1\UnitTestProject1\bin\Debug\UnitTestProject1.dll
Run started: C:\<snip>\UnitTestProject1\UnitTestProject1\bin\Debug\UnitTestProject1.dll
NUnit VS Adapter 2.0.0.0 executing tests is finished
========== Run test finished: 1 run (0:00:05.8321231) ==========


The reason this is an issue for me is I would like to migrate my test suite to NUnit. However, the current suite takes 2 seconds to run all the tests and adding another 5 seems painful.

I've done some googling around the issue but any answer is lost amongst complaints about NUnit running slowly in the console and general articles about speeding up tests.

I have tried the NUnit 3 test runner which had a similar time profile. I rolled back to version 2 because of other problems.

Is This A Good Question/Topic? 0
  • +

Replies To: Slow tests in Visual Studio

#2 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7447
  • View blog
  • Posts: 25,085
  • Joined: 05-May 12

Re: Slow tests in Visual Studio

Posted 22 February 2016 - 05:52 PM

I've not tried lately with VS2015, but xUnit, always started up very quickly for me as compared to NUnit or MSTest. And if launched through Resharper's menu, it was even faster.

Update: I just tried the latest xUnit with VS2015 without Resharper. I'll try again when I get to work which has a Resharper license. Using the Test Explorer, it is pathetically slow: 10 seconds turn around to run a test that supposedly took 28ms. Running the same test using CodeLens menus: 3 seconds to run the same 28ms test. I created a MSTest test using IntelliTest and tested the same thing: 7 seconds to run a 7ms test. I'll find it very hard to give up xUnit, and go back to MSTest.

This post has been edited by Skydiver: 22 February 2016 - 08:11 PM
Reason for edit:: Update with tests using xUnit and MSTest.

Was This Post Helpful? 1
  • +
  • -

#3 cfoley   User is offline

  • Cabbage
  • member icon

Reputation: 2410
  • View blog
  • Posts: 5,050
  • Joined: 11-December 07

Re: Slow tests in Visual Studio

Posted 23 February 2016 - 12:18 AM

Thanks for running those tests for me. 3 seconds still seems incredibly slow. Anyway, I'm running VS Community which I don't think can have CodeLens.

So, at least I know my current situation is "normal". :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1