C# &引用;nunit.framework.dll“;找不到
我正在学习NUnit教程 我的源文件位于文件夹C# &引用;nunit.framework.dll“;找不到,c#,nunit,C#,Nunit,我正在学习NUnit教程 我的源文件位于文件夹C:\Users\Me\Documents\visualstudio 2015\Projects\nunitest\nunitest中。我的NUnit DLL位于文件夹C:\ProgramFiles(x86)\NUnit.org\framework\3.2.0.0\portable\NUnit.framework.DLL中。我确信这些路径是正确的 为了将源文件AccountTest.cs编译成DLL,我运行了以下命令: cd C:\Users\Me\
C:\Users\Me\Documents\visualstudio 2015\Projects\nunitest\nunitest
中。我的NUnit DLL位于文件夹C:\ProgramFiles(x86)\NUnit.org\framework\3.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\3.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\3.2.0.0\portable\nunit.framework.dl
l' could not be found.
有什么建议吗
编辑:我没有忘记在解决方案中添加对NUnit的引用。我还使用语句包含了相应的
。您是否添加了对解决方案的引用
右键单击解决方案
将鼠标悬停在add上
点击参考
搜索Nunit引用并添加它
另外,请确保在所有类的项目顶部添加了using语句是否添加了对解决方案的引用
右键单击解决方案
将鼠标悬停在add上
点击参考
搜索Nunit引用并添加它
另外,确保在所有类的项目顶部添加了using语句,这是因为从命令行编译时没有引用NUnit程序集的路径。应该是这样,
csc /target:library /out:AccountTest.DLL /r:"C:\Program Files (x86)\NUnit.org\framework\3.2.0.0\portable\nunit.framework.dll" AccountTest.cs
您还应该知道,NUnit控制台目前无法使用框架的可移植版本运行测试。为此,您需要使用NUnitLite创建一个自执行测试程序集。现在,只使用.NET4.5版本的框架会更容易
您在命令行编译有什么原因吗?是免费的,将为您处理编译。如果您不在Windows上,则是另一个不错的选择。这是因为从命令行编译时没有引用NUnit程序集的路径。应该是这样,
csc /target:library /out:AccountTest.DLL /r:"C:\Program Files (x86)\NUnit.org\framework\3.2.0.0\portable\nunit.framework.dll" AccountTest.cs
您还应该知道,NUnit控制台目前无法使用框架的可移植版本运行测试。为此,您需要使用NUnitLite创建一个自执行测试程序集。现在,只使用.NET4.5版本的框架会更容易
您在命令行编译有什么原因吗?是免费的,将为您处理编译。如果您不在Windows上,这是另一个很好的选择。您添加了什么版本的NUnit
?您添加了什么版本的NUnit
?