Skip to content

Type args are not deduced correctly for parameterized fixtures #4243

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

Closed
estrizhok opened this issue Oct 25, 2022 · 2 comments · Fixed by #4307
Closed

Type args are not deduced correctly for parameterized fixtures #4243

estrizhok opened this issue Oct 25, 2022 · 2 comments · Fixed by #4307

Comments

@estrizhok
Copy link

estrizhok commented Oct 25, 2022

NUnit 3.13.1

Consider the following test class (from your own codebase):

[Category("Generics")]
[TestFixture(100.0, 42)]
[TestFixture(42, 100.0)]
public class DeduceTypeArgsFromArgs<T1, T2>
{
    T1 t1;
    T2 t2;

    public DeduceTypeArgsFromArgs(T1 t1, T2 t2)
    {
        this.t1 = t1;
        this.t2 = t2;
    }

    [TestCase(5, 7)]
    public void TestMyArgTypes(T1 t1, T2 t2)
    {
        Assert.That(t1, Is.TypeOf<T1>());
        Assert.That(t2, Is.TypeOf<T2>());
    }
}

Expected type args:

  1. System.Double, System.Int32
  2. System.Int32, System.Double

Actual type args:

  1. System.Double, System.Double
  2. System.Double, System.Double

P.S. I fixed it (and wrote tests) but could not commit to a new branch in your repository so as I could make a pull request. How do I do that?

remote: Permission to nunit/nunit.git denied to estrizhok.
fatal: unable to access 'https://github.com/nunit/nunit.git/': The requested URL returned error: 403
@mikkelbu
Copy link
Member

Hi @estrizhok
In order to make a PR you should.first clone the repository, the make a branch in the clone, and then create the PR against this repository

@stevenaw
Copy link
Member

stevenaw commented Nov 27, 2022

I can confirm this is happening. A simpler repro which should pass but instead fails on the second assertion:

[TestFixture(100.0, 42)]
public class DeduceTypeArgsFromArgs<T1, T2>
{
    T1 t1;
    T2 t2;

    public DeduceTypeArgsFromArgs(T1 t1, T2 t2)
    {
        this.t1 = t1;
        this.t2 = t2;
    }

    [Test]
    public void TestMyArgTypes()
    {
        Assert.That(t1, Is.TypeOf<double>());
        Assert.That(t2, Is.TypeOf<int>());
    }
}

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.

4 participants