Skip to content

Backwards Compatibility: TestMethods require zero parameters #199

@MikeChristensen

Description

@MikeChristensen

Description

Upon upgrading unit tests from legacy MSTest to MSTest v2, I ran into the following breaking change. TestMethods throw exceptions if there are parameters, rather than getting skipped.

Steps to reproduce

Repro code:

    [TestClass]
    public class UnitTests
    {
        [TestMethod]
        public void Works()
        {
            Assert.IsTrue(true);
        }

        [TestMethod]
        public void Breaks(string name)
        {
            Assert.IsTrue(true);
        }

        [TestMethod]
        public void AlsoBreaks(bool flag = false)
        {
            Assert.IsTrue(true);
        }
    }

Expected behavior

Legacy MSTest would ignore these methods completely. No errors or exceptions and they wouldn't get run. It would be somewhat useful if "AlsoBreaks" would get run using the default parameter values.

Actual behavior

Unit test framework throws a cryptic exception: "Parameter count mismatch".

Environment

Version .18 of MSTest on VS2015

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions