2

Question

For a large number of Unit Tests, Is there an easy way to generate a "OrderedTest" file for each test class within my project, allowing me to run each test method in the order that they appear within their respective classes?

Background

I have a large number(1000+) of Selenium Functional Tests contained within a Unit Test Project. In my project each class represents a page and each "Unit Tests" represents one of the my functional tests. Typically the tests are run in the following manner:

Create - Complex object within the page(10ish tests)

Manipulate\Edit - The already created complex object(100ish tests)

Tear-down\Delete - Remove the complex object piece by piece until the test page is resorted to its original state(10ish tests)

Due to the many complexities and load times of each page, each one of these tests(really just the groups) must be run in a specific order within their given class. I understand that this is "not optimal" to structure my tests in the manner, but unfortunately I have not found an alternative design for my tests to run in any reasonable amount of time.

I previously use ReSharpers test tool to run these tests, with this tool I'm able to run each test in the order that is appears in each class. Now I'm attempting(for various irrelevant reasons) to us MSTest to run my tests. MSTest runs each test by default in a "non-deterministic" order.

I would like to use "Ordered Tests" to enforce the order of each test. However, since I follow this convention my tests are currently not named in the order they are to be run. The order that I need to run the tests is currently defined by their order within their class.

So here's my problem, when I create a new "Ordered Test" file, the interface does not allow me to sort the "Avaliable tests" by their "natural order"(the order in which they appear in their class), it also does not allow me move the order of each of the "Selected Tests" more than one space(once per click). In a small scale project this would be just annoying, with my 1000+ test project(with many more 1000's on the way) it's very difficult to generate a ordered test for each one of my classes due to the overhead of having to order each item by hand.

Follow Up

The simpilist way I can think of to solve this is to write a script to generate "Orderedtest" files exactly as I've stated in my question, but it really strikes me as excessive, maybe I'm not following a standard(or recommended) path in coding my selenium test structure. I would think if many people had already followed this path, that there would be more documentation on the subject, but the little I find in relation to this subject does provide me with a clear path to follow.

I wonder if there is an alternate way that I can accomplish the same functionality with MSTest?

Community
  • 1
  • 1
David Rogers
  • 2,601
  • 4
  • 39
  • 84
  • No, I've modified the structure of my project so that I no longer have dependencies between tests, this brings up other [issues](http://programmers.stackexchange.com/questions/325803/selenium-test-design-struture-test-granularity-for-a-large-project) of course, but I still think that this is a valid question. I hope someone has a better idea then just scripting it out... – David Rogers Jul 26 '16 at 15:04

0 Answers0