Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-279447: Using a test case source in multiple tests leads to incorrect behavior

$
0
0
Reporter Philipp Dolder (philipp.dolder) Philipp Dolder (philipp.dolder)
Created Nov 9, 2011 6:17:26 PM
Updated Dec 8, 2011 10:01:58 PM
Resolved Nov 9, 2011 8:03:29 PM
Priority Normal
Type Bug
Fix versions 6.1
State Fixed
Assignee Victor Kropp (victor.kropp)
Subsystem Unit Testing
Affected versions 6.0
Fixed in build 6.1.1.12251
I have a NUnit test fixture with several tests that use the same test cases (property) with their "TestCaseSource" attribute. When running the tests I get incorrect test failures.

The following code reproduces the problem.

namespace ResharperNUnitTestCaseSource
{
    using System.Collections.Generic;

    using NUnit.Framework;

    [TestFixture]
    public class TestCaseSourceBugReproduction
    {

        public IEnumerable<TestCaseData> TestCases
        {
            get
            {
                yield return new TestCaseData(true).SetName("True");
                yield return new TestCaseData(false).SetName("False");
            }
        }

        [Test]
        [TestCaseSource("TestCases")]
        public void FirstTest(bool failsNot)
        {
            Assert.IsTrue(failsNot, "I expected true");
        }

        [Test]
        [TestCaseSource("TestCases")]
        public void SecondTest(bool fails)
        {
            Assert.IsFalse(fails, "I expected false");
        }
    }
}



I try to explain the behavior referring to the sample above.

If I only run a single test (e.g. FirstTest) I receive the test failure of SecondTest ("I expected false"). Using the debugger verifies, that all test cases are executed for FirstTest and after for SecondTest although I only executed FirstTest.

Running all the tests. I get the same behavior as above for FirstTest, but SecondTest is displayed as greyed out which denotes it is skipped.

It seems to mess up the test cases and failure messages.

Cheers
Philipp

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>