Learn more about Test Studio here
More you meet people more questions you get. I love this part of my job, meeting and answering people queries. I usually talk to Test Professional who are doing manual testing. So some of their questions are very basic and this is expected because they are not coming from coding or programming background.
Recently in one of seminar I came across a question
“How can I use MS Unit Test Assertion in a Test Step while automating test with Test Studio? “
Answer of this questions is in three steps,
Step 1:
Add reference of Microsoft.VisualStudio.QualityTools.UnitTestFramework dll in Test Project
Step 2:
Create a coded step
Step 3:
Write Assertion in test
Add Reference
There are in two ways you can work on Test Studio. Either on Visual Studio plugin or on Test Studio standalone version.
Adding reference in Visual Studio is simpler. Right click on test project and from context menu select Add Reference. Browse to Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll library and add reference in test project.
Even though you have added reference in Visual Studio make sure that you have added reference in test project opened in standalone version else you will get exception.
To add Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll assembly in Test Studio standalone version you need to follow following steps,
Select Project option in top menu
Click on Show Settings in project tab
On clicking on Show Settings you will get Project Settings dialog box. In dialog box click on Script Options. To add assembly reference click on Add Reference.
When you clock on Add Reference Test Studio will open File Chooser dialog box. In that browse Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll assembly reference location in file system and select that to add as reference in current Test project.
Create a coded step
To create Coded Step in select Test and from menu
You will find coded step added as below,
Write Assertion in Test
Once Coded step is added you can write any assertion. To validate I am writing a very simple assertion as below,
You can view below code in Visual Studio,
[CodedStep(@"New Coded Step")] public void WebTest_CodedStep() { Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual("TestStudio", "TestStudio"); }
In Test Studio standalone version codes step will look like as following,
Now go ahead and execute test. You should able to get test passed successfully as given below,
I hope you find this post useful. To speedup automated testing do not forget to download trial of Test Studio from here
Pingback: How to verify number of cookies while automating a test in Test Studio | Telerik Helper
Pingback: How to work with NUnit Assertion as step in Test Studio | Telerik Helper