Resharper9/Dotcover3 are giving different results for unit tests

Hello

Since upgrading to your latest releases, I'm having big discrepencies between results in Resharper and Dotcover.

One example between many others:

Class under test

    public class MyClass
    {
        public Uri TestUri { get; set; }

        public MyClass()
        {
            TestUri = new Uri("file://c:\\test.txt?Test=True");
        }
    }

Test
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace TestDotCover
{
    [TestClass]
    public class UnitTest1
    {
        private MyClass myClass = new MyClass();

        [TestMethod]
        public void TestQueryParemeter()
        {
            Assert.IsTrue(myClass.TestUri.Query.Length != 0);
        }
    }
}

With Resharper the test is a success whereas DotCover reports a failure. I've taken the example of the Uri but I've got many others where it is the case.

Thanks

Jonathan

4 comments

Hello Jonathan,

I've investigated the issue and found out that if there is no Test Settings item in a solution, dotCover always runs MSTests under .Net Framework 4.0, even if test projects are targeted to another framework version and even if you explicitly choose another framework in Unit Test Session Options. At the same time ReSharper uses native VS MSTests runner, and so doesn't have this bug. Therefore if your test projects are targeted to .Net 4.5 and your solution doesn't contain Test Settings item, ReSharper will run your tests by default under .Net 4.5 and dotCover - under .Net 4.0. In this case test results can be different for ReSherper and dotCover. Particularly your TestQueryParemeter test succeeds under .Net 4.5 and fails under .Net 4.0.

You can find more info about differences between .Net 4.0 and .Net 4.5 here: http://msdn.microsoft.com/en-us/library/hh367887%28v=vs.110%29.aspx

In order to force dotCover to run your tests under .Net 4.5 you can add Test Settings item to your solution. It doesn't matter what settings you will specify there. After you add a test settings file to the solution please specify the path to it in ReSharper's "Test Settings" option (ReSharper / Options / Tools / Unit Testing / MSTests).

Could you please tell me whether it solves the problem or not? Thanks in advance.

Best regards.

0

Hello Ekatarina,

This does indeed solve the issue that I was facing. Good stuff.

Has this behaviour changed in Dotcover 3? as I was not facing the issue with DotCover2.7 is seems that it was targetting automatically targetting 4.5

Thanks

Jonathan

0

Hello Jonathan,

I'm sorry for the delay!
Glad to hear that the problem is solved now.

Could you please specify what ReSharper/dotCover versions you used previously? I tried to reproduce the issue with dotCover 2.7.2 and as far as I see the bug is present there: TestQueryParemeter test fails on "Cover Unit Tests with dotCover" command, but succeeds on "Run Unit Tests" command.

Thanks. Best regards.

0

Hello Ekaterina,

Happy new year!

I confirm that the behaviour was the same in the previous version as well. The unit tests were written at the same time as the upgrade so I got that wrong....

Thanks

Jonathan

0

Please sign in to leave a comment.