Run NUnit test fixture programmatically

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-01 07:08:01

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!