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

Data in data driven test changes typ from double to int or decimal #1519

Closed
LosManos opened this issue Dec 31, 2022 · 2 comments
Closed

Data in data driven test changes typ from double to int or decimal #1519

LosManos opened this issue Dec 31, 2022 · 2 comments

Comments

@LosManos
Copy link

Describe the bug

Data driven data type gets converted from double to decimal or long.
This for types that are object.
MSTest.TestFramework version 3.0.2.

Look at the test below, it is easier than trying to explain in free form.

Steps To Reproduce

private static IEnumerable<object?[]> ADoubleType
{
    get
    {
        yield return new object[] { "double becomes decimal", new object[] { (double)1.1 } };
        yield return new object[] { "double becomes int", new object[] { (double)1.0 } };
    }
}

[DataTestMethod]
[DynamicData(nameof(ADoubleType))]
public void WichTypeIsThat(string message, object[] data)
{
    Assert.IsInstanceOfType<double>(data[0], message);
}

Expected behavior

The data type should be double and the test should be green.

Actual behavior

Assert.IsInstanceOfType failed. double becomes decimal Expected type:<System.Double>. Actual type:<System.Decimal>.
Assert.IsInstanceOfType failed. double becomes int Expected type:<System.Double>. Actual type:<System.Int32>.

Additional context

Not-easy-to-spot; the second parameter data is an array of object.

I cannot say whether this is a bug or working-as-intended. One can argue for both.
One can also argue that it is a bug but too special case to bother about.
But as I see ncrunch succeed it feels more like a bug.

It might work in v.2.0.0, because I noticed this when updating to 3.0.2. But on the other hand, I am not sure v.2.0.0. picked up the data driven test at all. When I reverted back to 2.0.0, my environment refused to run the test so I gave up on exploring full regression. Anyhow - the test code should be easy to run.

I am running the tests in Visual studio 17.4.2 (2022) if that matters.
MSTest.TestAdapter is v.3.0.2.
When running the test through dotnet test the test fails.
When running the test through ncrunch, it works as expected. I do not know how ncrunch runs test. Obviously not through dotnet test.

@ghost ghost added the Needs: Triage 🔍 label Dec 31, 2022
@Evangelink
Copy link
Member

Hi @LosManos,

Thanks for the report and sorry for triage time!

I confirm that there is an issue and that it's not a regression from 2.2.10. As far as I can see, this is one more example of problem caused by using the DataContractSerializer + algorithm put in place in MSTest.

I will keep this one open and link it to this ticket: #1462.

@Evangelink
Copy link
Member

Closing this one, please follow #1462 to get updates about the fix.

@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
Projects
None yet
Development

No branches or pull requests

2 participants