无法使用vstest.console.exe运行specflow测试

时间:2017-10-17 06:34:54

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

我正在尝试基于visual studio runner运行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作业中使用。

1 个答案:

答案 0 :(得分:0)

下面的代码行帮助我找出了现在需要修复的缺失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);
    }
相关问题