首页 > 解决方案 > 在 mac os (x64) 上的 specflow+ 示例测试

问题描述

我正在 使用 Visual Studio for mac 在 mac catalina(x64)上从这里运行 specflow+ 示例测试,但出现此错误

ExecutionThreadApartmentState option not supported for framework: .NETCoreApp,Version=v3.1.

由于这里apartmentState提到的 mac 不支持属性

我尝试apartmentState<execution>元素中删除,也尝试从中删除整个<execution>元素,Default.srprofile 但在测试结果输出中仍然出现相同的错误。(测试只是继续运行。取消后在测试输出中显示错误)

在构建中的平台设置中尝试过x64,但在尝试运行测试时我得到以下信息

Test run will use DLL(s) built for framework .NETCoreApp,Version=v3.1 and platform X86. Following DLL(s) do not match framework/platform settings. TestApplication.UiTests.dll is built for Framework .NETCoreApp,Version=v3.1 and Platform X64.

是不是上面提到的示例测试不能在 mac os (x64) 上运行?还是我错过了其他东西?

编辑 我安装并定位 .net core 3.0 并且仍然得到

ExecutionThreadApartmentState option not supported for framework: .NETCoreApp,Version=v3.0.

EDIT2 我在日志中看到的错误如下。我认为上述错误ExecutionThreadApartmentState可能只是一个警告,因为我仍然在测试输出中看到它

2020-04-29T13:55:54.5764790-04:00:Executing test executor at '/usr/bin/dotnet' 'exec "/Users/../Desktop/../projects/specflow/SpecFlow.Plus.Examples-master/SeleniumWebTest/TestApplication.UiTests/bin/Debug/netcoreapp3.0/SpecFlowPlusRunner/netcoreapp3.0/TechTalk.SpecRun.Framework.Executor.anycpu.netcoreapp3_0.dll" --remoteRunnerPid 37116 --uniqueId "2020-04-29T135554" --outputFolder "/Users/../Desktop/../projects/specflow/SpecFlow.Plus.Examples-master/SeleniumWebTest/TestApplication.UiTests/obj/TestResults" --callbackPort 32770 --loggerPort 32771' in '/Users/../Desktop/../projects/specflow/SpecFlow.Plus.Examples-master/SeleniumWebTest/TestApplication.UiTests/bin/Debug/netcoreapp3.0'
2020-04-29T13:55:54.6057600-04:00:System.ComponentModel.Win32Exception (2): No such file or directory
   at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at TechTalk.SpecRun.Framework.Execution.OutOfProc.OutProcExecutorManager.StartProcess(ExecutorProcessInfo executorProcessInfo)
   at TechTalk.SpecRun.VisualStudio.TestAdapter.VsOutProcExecutorManager.StartProcess(ExecutorProcessInfo executorProcessInfo)
   at TechTalk.SpecRun.Framework.Execution.OutOfProc.StreamJsonRPC.OutOfProcessTestAssemblyExecutorHost.Initialize(Int32 threadId, ITestExecutionManager executionManager, IAssemblyReference testAssembly, ITestLogger currentLogger, String testAssemblyFullPath, String testAssemblyConfigFilePath, TestExecutionConfiguration testExecutionConfiguration, String target) 

标签: c#.netspecflow

解决方案


我不是专家,还不是;)但我也遇到了这个错误。我发现它的发生是因为我在测试中声明了一个类变量——在它的构造函数中,通过控制台的 I/O 调用了存储在类字段中的对象的方法。当我从构造函数中删除调用时,测试(单元测试)可以再次运行。


推荐阅读