PlatformNotSupportedException: The following constructor parameters did not have matching fixture data

Viewed 361

I wrote some tests with dotnet core 2. This tests drive some Selenium's browsers. I developed the first test in local (using dotnet core 2.0 and xunit) and it workes like a charm.

Then I moved the project into Azure DevOps pipeline and I get this error:

System.PlatformNotSupportedException : Operation is not supported on this platform.

The following constructor parameters did not have matching fixture data

It seemed like in local development (a simple VS Code editor) someone inject automatically a Fixture inside contructors like that:

public AConstructor(TestFixture tf)
{
    this.tf = tf;
}

so I roughly rewrite it as:

public AConstructor(TestFixture tf)
{
    this.tf = new TestFixture();
}

but the problem is still there and I have no idea of what the problem is. In local development we setted up Selenium Grid with Docker, using the same version of the real grid. In Azure DevOps pipeline we reused the sample command used in local environment.

Any idea?

2 Answers

When I do this I normally structure it like this:

public class TestClass
{
    protected TestFixture testFixture { get; set; }

    public TestClass(TestFixture testFixture)
    {
        this.testFixture = testFixture;
    }
}

This allows you to create a local instance for use with your code.

Try this and let me know if it works for you.

Give the parameter a default value will fix it.

public AConstructor(TestFixture tf = null)
{
    this.tf = tf;
}
Related