Justdeserves
Justdeserves

Reputation: 49

MSTest Reused codedUI

I have a series of MS Unit tests in a class that I have created called Forename. The all run and pass sucessfully to test a variety of inputs e.g 100 chars max etc

I am now looking at getting CodedUI to find the forename and execute these test. I have managed to do this for one specific web page that has the forename control. I have managed to get this all working and pass.

I have now introduced a second page and I want to re-use the same set of test methods, and not have to repeat the code. I can defind and interface and implement and extract some methods to allow some re-use. I have tried to use inheritace, but am struggling and need some guidance if this is possible with MS Test.

Ideally I want to navigate to the page and run the forename tests. I then want to go to the second page and execute the extact same test.

All help appreciated.

Upvotes: 0

Views: 217

Answers (1)

marcel de vries
marcel de vries

Reputation: 128

It looks like you might want some guidance on how to set up CodedUI tests in such a way that they become maintainable. I can recommend you look at a concept called the PageObject pattern. Page Object pattern

You can do this with either the UIMap files you record, but personaly I like a code First approach better. You can find more details on writing codedUI without UI Map files here

It not only describes how you can map your web application to page objects, it also describes a way to build build out a Fluent API that makes your tests very easy to read and better maintainable.

Hope that helps.

Upvotes: 1

Related Questions