Search code examples
visual-studioapitestingsonarqubegallio

Testing Framework that supports Ordering of Test Classes and Test Methods


First of all: I don't want to do unit tests, instead I am going to implement API tests. These tests should be executed in a defined order:

  • Login
  • Get something
  • Create something
  • Logout

I'd like to get this work in Visual Studio as well as by SonarQube (Gallio is the test automation platform I am using).

My problem is just to find a framework that supports my requirements.

I've already tested:

  • MSTest -> Does not support ordered tests at all, except implementing the Ordered Test template that is not supported by any Gallio test runner plugin.
  • XUnit -> It is possible to implement an ordering for test methods within test classes, but it is not possible to order test classes.

Is there any testing framework that supports this requirement and provides runner for Visual Studio as well as an appropriate plugin for Gallio?


Solution

  • MSTest has a TestInitialize attribute that you can use to initialize each test. In it you could put your Login. There is also a TestCleanup attribute. There you could put your LogOut. The Get and Create would have to be within one method in order to ensure that the Get always happens before the Create.

    I am not familiar with SonarQube, so don't know whether it would handle this.