Specify order of execution of NUnit methods

Posted on 2011-10-12
Last Modified: 2012-05-12
In the NUnit test class I have 4 methods Insert,  Select, Update, Delete. But the order of execution is not in ther order what I mentioned in the class. The Delete method is getting executed first. This create problem for me. I want to force the order of execution of the methods. Any way to achieve that? I googled but no luck.

Any help is much appreciated. Thanks.
Question by:Easwaran Paramasivam
    LVL 74

    Accepted Solution

    From what I read, NUnit "chooses" the order of execution based on alphabetic ordering--because this is how Reflection returns the methods. You can give your methods names that are lexically in the order you want them to run (e.g. a_Insert, b_Update, c_Delete, etc.). It seems the philosophy for not allowing the explicit ordering of tests is that each test should be a distinct and self-contained unit, and as such should not depend on another test.
    LVL 16

    Author Comment

    by:Easwaran Paramasivam
    Thanks for your comments. Is there any other way such as mentioning the order of the execution in any of the attribute? Because we follow the naming convention to methods.
    LVL 9

    Expert Comment

    I have checked but there is not other way, I think what kaufmed says is the  only way.
    LVL 16

    Author Closing Comment

    by:Easwaran Paramasivam
    I'll follow your comments for workaround. Thanks.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
    This video discusses moving either the default database or any database to a new volume.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now