Justdeserves
Justdeserves

Reputation: 49

Automated application testing with TFS

I think I'm missing a link somewhere in how microsoft expect TFS and automated testing to work together. TFS allows us to create test cases that have test steps. These can be merged into a variety of test plans. I have this all setup and working as I would expect for manual testing.

I've now moved into automating some of these tests. I have created a new visual studio project, which relates to my test plan. I have created a test class that relates to the test case and planned to create a test method for each test step within the test class, using the ordertest to ensure that the methids are executed in the same order as the test steps.

I'd hoped that I could then link this automation up to the test case so that it could be executed as part of the test plan.

This is when it all goes wrong, It is my understanding that the association panel appears to only hook a test case up to a particular test method, not a test step?

Is my understanding correct?

Have MS missed a trick here and made things a litte too complicated or have I missed something? If I hook things upto a whole test case to a method I lose granulaity of what each is doing.

If each test step was hooked into a test method it would be possible for the assert of the test method to register a pass or fail of the overall test case.

Any help or direction so that I can improve my understanding would be appreciated.

Upvotes: 0

Views: 530

Answers (2)

SarkarG
SarkarG

Reputation: 687

You can link only one method to a test case. That one method should cover all the steps written in its associated test case including verification(assertions).

If it is getting impossible to cover all steps in one test method or if your have too many verifications is your test case, then the test case needs to be broken down to smaller test cases and each of the test cases will have one automated method associate with it.

Automation test should work like this. (Not a hard rule though..)

Start -> Do some action -> Verify (Assert) -> Finish

You can write as many assertions as possible, but if first assert fails then test won't proceed further to do other assertions. This is how manual testing also works, ie Test fails even if 1 step out of 100 fails.

For the sake of automation test maintainability it is advisable to add minimum asserts in automation test and easiest way to achieve this is by splitting the test case. Microsoft or other test automation provider works this way only and we don't write test methods for each and every steps. This would make things very complicated.

But yes, you can write reusable methods(not test methods) in your test framework for each steps and call them in your test methods. For example you don't have to write code for a test case step say "Application Login" again and again. You can write your method separately and call that in your test method which is linked to the test case.

Upvotes: 1

AdrianHHH
AdrianHHH

Reputation: 14038

The link is not obvious. In Visual Studio Team Explorer create and run a query to find the test case(s). Open the relevant test case and view the test automation section. On the right hand side of the test automation line there should be an ellipsis, click it and link to the test case.

I view this as pushing an automated test from Visual Studio. Confusingly you cannot pull an automated test into MTM.

Upvotes: 1

Related Questions