Firstly we need to install NSpec and NSpec adapter for xUnit on our test project, we can use Package Manager to install those easily.
Then add a class in the project and put the code below:
using NSpec; class my_first_spec : nspec { void given_the_world_has_not_come_to_an_end() { it["Hello World should be Hello World"] = () => "Hello World".should_be("Hello World"); } }
Build the project then run this command on Package Manager Console:
nspecrunner [your_test_project]\bin\debug\[your_test_project].dllYou should get this result:
my first spec given the world has not come to an end Hello World should be Hello World 1 Examples, 0 Failed, 0 Pending
If you had this error "The term 'nspecrunner' is not recognized as the name of a cmdlet, function, script file, or operable program" then it seems that the files are not copied properly by PM. You could resolve this issue by manually copying the missing files.
Go to '[your_solution_folder]\packages\nspec.0.9.66\tools' folder then copy these two files; NSpecRunner and NSpecRunner.exe, to '[your_project_folder]\bin\debug' folder.
Restart Visual Studio then run the command again.