Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamicData test is not passing exception objects correctly #1037

Closed
krishnajay0310 opened this issue Feb 7, 2022 · 1 comment
Closed

DynamicData test is not passing exception objects correctly #1037

krishnajay0310 opened this issue Feb 7, 2022 · 1 comment

Comments

@krishnajay0310
Copy link

krishnajay0310 commented Feb 7, 2022

We are using DynamicData to specify our test cases. We are creating an InvalidUpdateException object by passing custom exception message. However, the exception message being actually passed to the unit test method is “Exception of type ‘CCO.Contracts.InvalidUpdateException' was thrown.”

Steps to reproduce

        private static IEnumerable<object[]> TestData()
        {
            return new List<object[]>()
            {
            new object[] { new InvalidUpdateException("Test exception message") }
            };
        }        
        [DynamicData(nameof(TestData), DynamicDataSourceType.Method)]
        [TestMethod]
        public void ValidateExMessage(Exception ex)
        {
            Assert.AreEqual(ex?.Message, "Test exception message");
        }

Expected behavior

ex?.Message = "Test exception message"

Actual behavior

ex?.Message = "Exception of type ‘CCO.Contracts.InvalidUpdateException' was thrown"

Environment

Windows OS
Using Visual Studio 2022
Nuget package versions -

<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.0.0" />
 <PackageReference Update="MSTest.TestAdapter" Version="2.2.8" />
 <PackageReference Update="MSTest.TestFramework" Version="2.2.8" />
@Evangelink
Copy link
Member

Please follow #1462 to get updates about the fix of this issue.

@Evangelink Evangelink closed this as not planned Won't fix, can't repro, duplicate, stale Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants