【问题标题】:Unable to run specflow tests using vstest.console.exe无法使用 vstest.console.exe 运行 specflow 测试
【发布时间】:2017-10-17 06:34:54
【问题描述】:

我正在尝试基于 Visual Studio 运行程序运行 speflow 测试,但在 vsts 中出现错误。我正在使用以下vsts 测试运行器任务:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe myassembly.dll

错误:

System.Reflection.ReflectionTypeLoadException:无法加载一种或多种请求的类型

检索 LoaderExceptions 属性以获取更多信息。

我试过了:

/TestAdapterPath: "Adapterpath"/UseVsixExtensions:True/False(Both option)/Platform:[ platform type ] 

...但这些都不起作用;测试在 Visual Studio 2017 中运行良好,但仍无法在 CI 工作中运行。

【问题讨论】:

  • 您将哪个测试运行器与 VSTest 结合使用? SpecFlow+Runner、MsTest、XUnit、NUnit?
  • @AndreasWillich 这是 xunit
  • 是核心测试项目吗?你能用一个新项目重现这个问题吗?将 system.debug 变量设置为 true,然后在 OneDrive 上排队构建并共享详细日志。
  • 是的,它是核心测试项目。
  • 可以分享一下OneDrive上的详细日志吗?你能用一个新项目重现这个问题吗?

标签: visual-studio-2017 azure-devops specflow azure-pipelines-build-task


【解决方案1】:

下面的代码行帮助我识别丢失的 dll,现在它是需要修复的构建。

try
    {
    }
    catch (System.Reflection.ReflectionTypeLoadException ex)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        foreach (System.Exception exSub in ex.LoaderExceptions)
        {
            sb.AppendLine(exSub.Message);
            System.IO.FileNotFoundException exFileNotFound = exSub as System.IO.FileNotFoundException;
            if (exFileNotFound != null)
            {
                if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
                {
                    sb.AppendLine("Fusion Log:");
                    sb.AppendLine(exFileNotFound.FusionLog);
                }
            }
            sb.AppendLine();
        }
        string errorMessage = sb.ToString();
        throw new System.Exception(errorMessage);
    }

【讨论】:

    猜你喜欢
    • 2015-08-20
    • 2022-01-02
    • 1970-01-01
    • 2015-05-04
    • 2021-01-30
    • 1970-01-01
    • 2021-10-09
    • 1970-01-01
    • 2018-10-31
    相关资源
    最近更新 更多