PlatformNotSupportedException:以下构造函数参数没有匹配的灯具数据

时间:2018-12-18 15:24:19

标签: c# .net-core selenium-grid xunit.net

我用dotnet core 2编写了一些测试。该测试驱动了一些Selenium的浏览器。我开发了第一个本地测试(使用dotnet core 2.0和xunit),它的工作原理很吸引人。

然后我将项目移到Azure DevOps管道中,并出现此错误:

  

System.PlatformNotSupportedException :该平台不支持该操作。

     

以下构造函数参数没有匹配的灯具   数据

在本地开发(一个简单的VS Code编辑器)中,好像有人自动将一个Fixture注入到这样的构造函数中:

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

所以我大致将其重写为:

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

但是问题仍然存在,我不知道问题是什么。在本地开发中,我们使用相同版本的真实网格,通过Docker建立了Selenium Grid。在Azure DevOps管道中,我们重复使用了本地环境中使用的示例命令。

有什么主意吗?

2 个答案:

答案 0 :(得分:0)

当我这样做的时候,我通常是这样构造的:

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

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

这允许您创建一个本地实例以与代码一起使用。

尝试一下,让我知道它是否适合您。

答案 1 :(得分:0)

为该参数提供默认值即可解决该问题。

public AConstructor(TestFixture tf = null)
{
    this.tf = tf;
}
相关问题