Test Automation with Telerik I
By Kasun Ratnayake
Automating with Telerik Test Studio is really simple and its free!! its just a matter of creating a test in Visual studio and you are set.
This article is using Visual Studio to create a simple test automation project.
First of all you should download and install the Telerik Testing Framework, as I said before its free and its a very powerful framework.
- Use the below link to download Telerik Testing Framework, did I mention that its FREE??
Download Telerik Testing Framework
2. Now install the package, to your computer.
3. Open visual studio Select New project
4. Create a Unit Test Project from Visual Studio
If you’re using Telerik Test studio Free framework Use Visual studio as your IDE. You could select new project like in the Figure 1 screenshot and select “Unit Test Project
Then Select new Item and Under Test you can select new VsUnit test from adding a new Item. You can use a Simple Unit test for this but then you have to write the initialize and tear down methods by yourself. So use this “VS unit test ” option [Figure 2]
So your test will look like below
and your test you could see a template with several test methods such as
- MyClassInitialize
- MyTestInitialize
- MyTestCleanup
- MyClassCleanup
You can declare or initialize any variables in the MyClassInitialize
If you’re using couple of testes in side one class you can use MyTestInitialize declare or initialize any variables for that particular test. If you have to clean something in each test you can add it on MyTestCleanup
Ex: browser
If you have to clean something at the end of the class you can use MyClassCleanup to clean that variable
Ex: Manager
Then you can create a Test Method in between MyTestInitialize and MyTestCleanup
Your new test methods will look like this
[TestMethod]
public void TestMethod1()
{
}
You can Write your test Scripts inside this method
[TestMethod]
public void TestMethod2()
{
Settings mySettings = new Settings();
mySettings.Web.DefaultBrowser = BrowserType.InternetExplorer; Manager myManager = new Manager(mySettings); myManager.Start(); myManager.LaunchNewBrowser(); myManager.ActiveBrowser.NavigateTo("www.google.com");
//Add Some assertion
myManager.Dispose();
}
How to Run the test
In visual studio open the Test menu
Select Test> Windows> Test Explorer
Inside test explorer you new test will be listed if not, build the solution and check the Test Explorer
TestMethod2 will be listed inside the Test Explorer, Right click it and select “Run Selected Tests” or “Debug Selected Tests”with that your test will start running,
About the Author
Kasun has over 6 years of experience in both Software Development and Software Quality Assurance streams. He is a test automation specialist experienced in many automation tools including Telerik, Selenium, QTP and CodedUI. He is passionate about the technical aspects of testing and has created automation frameworks to facilitate automation in several domains including Finance, Insurance, Enterprise Performance Management and CRM.