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

Fix parameters/arguments check for data driven tests #2829

Merged
merged 4 commits into from
May 7, 2024

Conversation

nohwnd
Copy link
Member

@nohwnd nohwnd commented May 7, 2024

This fixes regression, where we validate types of provided data (e.g. in [DataRow]) to the expected parameters of the test method exactly by their types. This is too strict and will fail for any types that can implicitly convert.

This PR simply invokes the method, and relies on runtime to do the right checks, and we just handle and improve the exceptions that it throws. We only handle the two that are documented here: https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase.invoke?view=net-8.0 as happening when parameters don't match the target method.

As a result, user can provide int32 number to int64 parameter and it will work. As mentioned in the linked issue.

Fix #2828

@nohwnd nohwnd requested a review from Evangelink as a code owner May 7, 2024 11:40
@Evangelink Evangelink changed the title Make parameter checking less strict for data driven tests Fix parameters/arguments check for data driven tests May 7, 2024
Co-authored-by: Amaury Levé <amauryleve@microsoft.com>
Evangelink
Evangelink previously approved these changes May 7, 2024
@Evangelink Evangelink enabled auto-merge (squash) May 7, 2024 11:49
@Evangelink Evangelink merged commit 6a52336 into main May 7, 2024
6 checks passed
@Evangelink Evangelink deleted the fix-parameter-validation branch May 7, 2024 14:28
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

Successfully merging this pull request may close these issues.

[3.4 preview] Test parameter type check is very strict
2 participants