Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define dependency between tests in MStest

I have some tests which are dependent on the success and failure of some tests. How can I define dependency as I am using VS2010 Mstest and selenium. E.g

if test1 is failed then dont run test5, test 6. is this possible.

like image 901
sam Avatar asked Mar 02 '11 12:03

sam


2 Answers

Unit Tests should always be isolated and completly non dependent on and thing else to run, not make non-fragile.

You could setup catagories with MSTest to seperate them into deferent logical structures.

A great book to find more details is this http://artofunittesting.com

Roy has also does alot of public speaking which is recorded online

Cheers

like image 65
Iain Avatar answered Sep 29 '22 18:09

Iain


Tests shouldn't have dependencies between them.

If you have dependencies, then running them in a different order, or in isolation will cause them to fail sporadically - this can be very confusing for anyone else that is running the tests.

It's much better to define tests that setup their own data and assert something specific. You can use a mocking framework like Rhino Mocks to reduce the dependencies between modules of code by faking (mocking) areas that aren't relevant to your test. This is made much easier if you also use a dependency injection framework like Microsoft Unity as your code will have many more seams where mocking can be applied.

like image 43
sheikhjabootie Avatar answered Sep 29 '22 17:09

sheikhjabootie