4

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?

BAD_SEED
  • 4,840
  • 11
  • 53
  • 110
  • Is the pipeline setup to be [Interactive](https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/agents?view=vsts#account)? – rickvdbosch Dec 18 '18 at 15:26

2 Answers2

0

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.

J.R. Bye
  • 98
  • 2
  • 12
  • Check out this question. https://stackoverflow.com/questions/39440942/xunit-the-following-constructor-parameters-did-not-have-matching-fixture-data It may shed some light on it possibly. – J.R. Bye Dec 28 '18 at 15:08
  • This one also: https://stackoverflow.com/questions/43520648/xunit-test-constructor-dependence-injection-with-autofac – J.R. Bye Dec 28 '18 at 15:09
0

Give the parameter a default value will fix it.

public AConstructor(TestFixture tf = null)
{
    this.tf = tf;
}
shingo
  • 18,436
  • 5
  • 23
  • 42