我在从命令行运行测试时遇到了一些问题。我有一个单独的测试项目,通常使用Rider,测试运行得无懈可击。但是,我希望在CI环境中运行它们,因此需要能够从命令行运行它们。
我正在尝试运行Projectname>"C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe“Test\Test.csproj NUnit Console Runner 3.4.0版权所有(C) 2016查理普尔
Runtime Environment
OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
CLR Version: 4.0.30319.42000
Test Files
Test\Test.csproj
Errors and Failures
1) Error : Test.MVCmodel.CoilClassTest.CoilCreateEmptyIdTest
System.BadImageFormatException : Could not load file or assembly 'UserInterface, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
at Test.MVCmodel.CoilClassTest.CoilCreateEmptyIdTest()运行"C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe“Test\bin\Debug\Test.dll”时也会发生同样的情况
测试项目位于MainProject中: Projectname\Projectname.csproj和Projectname\Test\Test.csproj
是的,我在Stackoverflow上发现了相当多类似的帖子,但我没有找到适用的解决方案。
发布于 2019-11-01 02:18:30
这为我解决了这个问题。在build settings下,将平台目标更改为x86

当然,这是假设UserInterface存在并在CLI环境之外良好地运行(如在visual studio中)。
https://stackoverflow.com/questions/47198264
复制相似问题