以编程方式运行NUnit测试装置我经常想做快速测试并在LINQPad中编写代码。所以我有一个Main()入口点。我可以通过编程方式让NUnit从那里“运行”一个夹具吗?使用NUnit.Framework;publicclassRunner{publicstaticvoidMain(){//我在这里做什么?}[TestFixture]publicclassFoo{[Test]publicvoidTestSomething(){//testsomething}}}你可以使用NUnitLiteRunner:usingNUnit.Framework;使用NUnitLite;公共类Runner{publicstaticintMain(string[]args){returnnewAutoRun(Assembly.GetExecutingAssembly()).Execute(newString[]{"/test:Runner.Foo.TestSomething"});}[TestFixture]publicclassFoo{[Test]publicvoidTestSomething(){//testsomething}}}这里“/run:Runner.Foo”指定了文本夹具。请注意,您还必须引用nunitlite.dll包。3.7中引入的问题将在使用3.8时得到修复。这是否明确适用于LINQPad,我不确定。您可以使用MyGetFeed中的最新版本进行试用。以上就是C#学习教程:ProgrammaticallyruntheNUnittestfixture所有内容分享。如果对你有用,需要进一步了解C#学习教程,希望大家多多关注。本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
