tags:

views:

266

answers:

2

I try to use NUnit with SnippetCompiler http://www.sliver.com/dotnet/SnippetCompiler/

I have added references to nunit.framework.dll in snippetcompiler (Menu Tools, References) and compiled nunit sample http://www.nunit.org/index.php?p=quickStart&r=2.5.2 to bank.dll

but when I open bank.dll in NUnit GUI it fails saying it cannot load NUnit assembly or one of its dependencies.

Is it possible to fix this ?

+2  A: 

I couldn't even get v2.0.8.3 of SnippetCompiler to include the reference. It let me do it, but it wouldn't compile.

In any case writing unit tests isn't the purpose of SnippetCompiler. It's designed to do quick spikes - try something and see if it works. In other words, it's throwaway code.

In addition, the version for .NET 3.5 (the one I'm using) is an alpha release; the developer does not seem to be maintaining this. (Not to put down the author - this was an awesome tool that saved me lots of time!)

For writing spikes against modern versions of .NET, I've switched to LINQPad. Change Edit/Preferences/Query to C# Program and it's very similar to SnippetCompiler. The basic version is free; for a small fee, the registered version provides IntelliSense.

Even if you're writing learning tests with NUnit, you'll want to preserve those tests. Use Visual Studio (or another IDE) and create a separate Class Library project for your tests.

TrueWill
As for me I can add the reference. The purpose of my question is not how to use NUnit, but why NUnit doesn't work with SnippetCompiler, it's more about a question on how .NET really works.
programmernovice
@programmernovice: "NUnit doesn't work with SnippetCompiler" doesn't have a great deal to do with .NET. If one of the puposes of this site is for novices to learn from the more experienced then I would humbly suggest using a Test Runner just like everyone else.
Mitch Wheat
There's no reason why NUnit wouldn't work with SnippetCompiler since SnippetCompiler can add References to Assembly. So is there something more NUnit needs ?
programmernovice
A: 

Maybe this is the solution

http://weblogs.asp.net/rosherove/archive/2008/02/21/ad-hoc-unit-tests-with-snippet-compiler.aspx

Ad hoc Unit Tests with Snippet Compiler

If you're a fan of snippet compiler (if you're not you should seriously check it out)Travis Illig published a little template for writing Typemock Isolator test inside this handy little tool.

the reasons you'd need a specialized template in the first place to write these kinds of tests in snippet compiler:

1) Typemock Isolator uses the .NET profiling APIs to work its magic, so the .net process running your tests need to have a couple of environment variables enabled to work

2) His code template actually creates and runs a new process that triggers nunit-console.exe with the path of the current code you just wrote in snippet compiler allowing you to effecively write and run unit tests in snippet compiler!

3) the nunit-console process will already have the env. vars as mentioned in the first item set to it.

Travis' template will work for anything nunit can run, not just typemock isolator tests, which is pretty cool.

programmernovice