"nunit.framework.dll" 找不到
"nunit.framework.dll" could not be found
我正在学习 NUnit 教程 here。
我的源文件位于文件夹 C:\Users\Me\Documents\Visual Studio 2015\Projects\NUnitTest\NUnitTest
中。我的 NUnit DLL 位于文件夹 C:\Program Files (x86)\NUnit.org\framework.2.0.0\portable\nunit.framework.dll
中。我确信这些路径是正确的。
为了将源文件AccountTest.cs
编译成DLL,我运行执行了以下命令:
cd C:\Users\Me\Documents\Visual Studio 2015\Projects\NUnitTest\NUnitTest
C:\Users\Me\Documents\Visual Studio 2015\Projects\NUnitTest\NUnitTest>csc /target:library /out:AccountTest.DLL /r:C:\Program Files (x86)\NUnit.org\framework.2.0.0\portable\nunit.framework.dll AccountTest.cs
但是,我看到了这些错误消息:
error CS2001: Source file 'C:\Users\Me\Documents\Visual Studio 2015\Projects\N
UnitTest\NUnitTest\Files' could not be found.
error CS2001: Source file 'C:\Users\Me\Documents\Visual Studio 2015\Projects\N
UnitTest\NUnitTest\(x86)\NUnit.org\framework.2.0.0\portable\nunit.framework.dl
l' could not be found.
有什么建议吗?
编辑: 我没有忘记在我的解决方案中添加对 NUnit 的引用。我还包含了适当的 using
语句。
您是否添加了对您的解决方案的引用?
右击解决方案
将鼠标悬停在添加
点击参考
搜索 Nunit 参考并添加它
此外,请确保您已在所有 类
项目的顶部添加了 using 语句
因为你在命令行编译的时候没有引用NUnit程序集的路径。应该是这样的,
csc /target:library /out:AccountTest.DLL /r:"C:\Program Files (x86)\NUnit.org\framework.2.0.0\portable\nunit.framework.dll" AccountTest.cs
您还应该知道 NUnit 控制台目前无法 运行 使用框架的可移植版本进行测试。为此,您需要使用 NUnitLite 创建一个自执行测试程序集。现在,您只使用框架的 .NET 4.5 版本会更容易。
你在命令行编译有什么原因吗? Visual Studio Community Edition is free and will handle compiling for you. If you are not on Windows, MonoDevelop 是另一个不错的选择。
我正在学习 NUnit 教程 here。
我的源文件位于文件夹 C:\Users\Me\Documents\Visual Studio 2015\Projects\NUnitTest\NUnitTest
中。我的 NUnit DLL 位于文件夹 C:\Program Files (x86)\NUnit.org\framework.2.0.0\portable\nunit.framework.dll
中。我确信这些路径是正确的。
为了将源文件AccountTest.cs
编译成DLL,我运行执行了以下命令:
cd C:\Users\Me\Documents\Visual Studio 2015\Projects\NUnitTest\NUnitTest
C:\Users\Me\Documents\Visual Studio 2015\Projects\NUnitTest\NUnitTest>csc /target:library /out:AccountTest.DLL /r:C:\Program Files (x86)\NUnit.org\framework.2.0.0\portable\nunit.framework.dll AccountTest.cs
但是,我看到了这些错误消息:
error CS2001: Source file 'C:\Users\Me\Documents\Visual Studio 2015\Projects\N
UnitTest\NUnitTest\Files' could not be found.
error CS2001: Source file 'C:\Users\Me\Documents\Visual Studio 2015\Projects\N
UnitTest\NUnitTest\(x86)\NUnit.org\framework.2.0.0\portable\nunit.framework.dl
l' could not be found.
有什么建议吗?
编辑: 我没有忘记在我的解决方案中添加对 NUnit 的引用。我还包含了适当的 using
语句。
您是否添加了对您的解决方案的引用?
右击解决方案 将鼠标悬停在添加 点击参考 搜索 Nunit 参考并添加它
此外,请确保您已在所有 类
项目的顶部添加了 using 语句因为你在命令行编译的时候没有引用NUnit程序集的路径。应该是这样的,
csc /target:library /out:AccountTest.DLL /r:"C:\Program Files (x86)\NUnit.org\framework.2.0.0\portable\nunit.framework.dll" AccountTest.cs
您还应该知道 NUnit 控制台目前无法 运行 使用框架的可移植版本进行测试。为此,您需要使用 NUnitLite 创建一个自执行测试程序集。现在,您只使用框架的 .NET 4.5 版本会更容易。
你在命令行编译有什么原因吗? Visual Studio Community Edition is free and will handle compiling for you. If you are not on Windows, MonoDevelop 是另一个不错的选择。