I often want to perform a quick test, and code it up in LINQPad.
So I have a Main()
entry point. Can I make NUnit "run" a fixture programmatically from there?
using NUnit.Framework;
public class Runner
{
public static void Main()
{
//what do I do here?
}
[TestFixture]
public class Foo
{
[Test]
public void TestSomething()
{
// test something
}
}
}
You can use the NUnitLite Runner:
using NUnit.Framework;
using NUnitLite;
public class Runner {
public static int Main(string[] args) {
return new AutoRun(Assembly.GetExecutingAssembly())
.Execute(new String[] {"/test:Runner.Foo.TestSomething"});
}
[TestFixture]
public class Foo {
[Test]
public void TestSomething() {
// test something
}
}
}
Here "/run:Runner.Foo"
specifies the text fixture.
Mind that you have to reference the nunitlite.dll
package as well.
With 3.8, the problem that was introduced in 3.7 will be fixed. Whether that works explicitly with LINQPad, I'm not sure. You could try it out using the latest build from our MyGet feed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With