添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am following the NUnit tutorial here .

My source files live in the folder C:\Users\Me\Documents\Visual Studio 2015\Projects\NUnitTest\NUnitTest . My NUnit DLL lives in the folder C:\Program Files (x86)\NUnit.org\framework\3.2.0.0\portable\nunit.framework.dll . I am certain that these paths are correct.

To compile the source file AccountTest.cs into a DLL, I ran the following commands:

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

However, I see these error messages:

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.

Any advice?

EDIT: I didn't forget to add a reference to NUnit inside of my solution. I also included the appropriate using statement.

It is because you did not quote the path to the NUnit assembly when you compiled from the command line. It should be this,

csc /target:library /out:AccountTest.DLL /r:"C:\Program Files (x86)\NUnit.org\framework\3.2.0.0\portable\nunit.framework.dll" AccountTest.cs

You should also know that the NUnit Console cannot run tests using the portable version of the framework at the moment. To do that, you need to create a self-executing test assembly using NUnitLite. For now, it would be easier for you to just use the .NET 4.5 version of the framework.

Is there any reason you are compiling at the command line? Visual Studio Community Edition is free and will handle compiling for you. If you are not on Windows, MonoDevelop is another good option.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.