c# - Run TestFixtures in Order with NUnit -
i need have ordered test fixtures in nunit c# application. have example on how run ordered test methods this page, , i've tried implement same logic test fixtures same methods provided in example application. in our application test fixture separated each class , each test fixture has 1 test method. our latest attempt use parent test fixture inherits class called: orderedtestfixture (the same in example), has following method:
public ienumerable<nunit.framework.testcasedata> testsource { { var assembly = assembly.getexecutingassembly(); foreach (var order in methods.keys.orderby(x => x)) { foreach (var methodinfo in methods[order]) { methodinfo info = methodinfo; yield return new nunit.framework.testcasedata( new teststructure { test = () => { object classinstance = activator.createinstance(info.declaringtype, null); info.invoke(classinstance, null); } }).setname(methodinfo.name); } } } } this method supposed return, in order, test methods execute. however, if returns test methods in order, fails execute them in order.
i'm using same exact logic in app example. orderedtestattrribute class inherits attribute placed in every test method this:
[test] [orderedtest(1)] [beforeaftertest] public void testmethod() { } does out there have idea how can make work without changing current implementation of having 1 testfixture 1 test class separately?
ok, if understand correctly, want order test across multiple testfixtures. in case, don't want use orderedtestfixture because created not run test across multiple fixtures. if @ github repo earlier question, you'll want follow example 2 code. note in case should use orderedtest attribute - using test throw whole thing off because randomly scheduled nunit instead of being ordered through use of testcasedata. refer my blog post more details.
hope helps.
Comments
Post a Comment