测试项目未找到已测试的项目 dll



我正在尝试查看是否可以实现此处列出的建议:

http://www.ndepend.com/Res/NDependWhiteBook_Assembly.pdf

  • 我将主项目设置为命令行应用程序。
  • 我的
  • 测试项目引用了我的 cmdln应用程序,复制本地 = 假。
  • 有我的主要项目设置要输出到..\构建\调试(调试时)
  • 我有我的测试项目设置要输出到..\构建\测试\

我的测试项目中有一个具有以下设置的 app.config:

<configuration>
    <runtime>
            <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                <probing privatePath="debug;debuglib;tests;" />
                <dependentAssembly>
                        <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                    <bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
                </dependentAssembly>
                <dependentAssembly>
                    <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                    <bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
                </dependentAssembly>
                <dependentAssembly>
                    <assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
                    <bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
                </dependentAssembly>
                <dependentAssembly>
                    <assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral" />
                    <bindingRedirect oldVersion="0.0.0.0-2.6.4.14350" newVersion="2.6.4.14350" />
                </dependentAssembly>
            </assemblyBinding>
    </runtime>
    <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
    </startup>
</configuration>

当我尝试运行我的单元测试时,我收到一个错误: System.IO.FileNotFoundException :无法加载文件或程序集"CmdLnApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" 或其依赖项之一。

我已经检查并正在创建构建文件夹,调试文件夹包含来自 CmdLnApp 的所有文件,构建文件夹还有一个包含所有测试库的测试文件夹。

谁能看到我错过了什么?

经验法则:所有代码都必须位于外部 DLL 中。它使它更易于测试。exe 中的任何内容都可以由用户、UI 自动测试或使用命令行参数调用 exe 进行测试。所有这些都很麻烦,并且容易失败。更正您的设置,您将不会有任何问题。

最新更新