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

[3.4 preview] Test parameter type check is very strict #2828

Closed
cremor opened this issue May 7, 2024 · 1 comment · Fixed by #2829
Closed

[3.4 preview] Test parameter type check is very strict #2828

cremor opened this issue May 7, 2024 · 1 comment · Fixed by #2829
Assignees
Milestone

Comments

@cremor
Copy link

cremor commented May 7, 2024

Describe the bug

After updating MSTest from 3.3.1 to 3.4.0-preview.24257.1 I noticed that one of my data driven tests now fails because of a method parameter type mismatch. But the test ran fine in all versions before 3.4.

Steps To Reproduce

Example test:

      [TestMethod]
      [DataRow("Field", "Customer", 1, null)]
      public void TestMethod(string field, string entityType, long entityId, string richTextValue)
      {
      }

Expected behavior

Test passes.

Actual behavior

Test fails with this message:

Test data doesn't match method parameters. Either the count or types are different.
Test expected 4 parameter(s), with types 'String, String, Int64, String',
but received 4 argument(s), with types 'String, String, Int32, null'.

Additional context

I assume the problem is only Int32 vs. Int64.
Is this type check so strict on purpose? Isn't the implicit conversion (which worked in older MSTest versions) enough?

I think this is caused by #2691

@nohwnd
Copy link
Member

nohwnd commented May 7, 2024

That is a good point.

The new code seems to be too clever for its own good. We should probably give up on validating the types beforehand, and just use the logic to figure out if we are handing params parameters or not and then wait if the test fails with "Parameter count mismatch" exception, and throw our better exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants