Create a Data Driven Test with Telerik Testing Framework | Adding the Data file to a Folder




Automating with Telerik Test Studio using data driven testing is simple, its just a matter of clicking on some controls and you are set. IF you need any information regarding that please click on the following link

URL: http://docs.telerik.com/teststudio/features/data-driven-testing/overview

But if you're using Telerik Test Studio free framework for your test automation  its not easy as clicking on buttons.

But its not that hard.

First of all you should create a Unit test 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 a New VS unit 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



Then you can create a Test Method in that Unit test

Your new test methods will look like this

 [TestMethod]  
     public void TestMethod1()  
     {  
     }  


You can Write your test Scripts inside this method

Eg;

In here First we  create a new settings instance
then initializing the brwoser
Add the previously initialized settings to Manager
Start manager
Launch browser
Navigate to your URL and start testing

 [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();  
     }  



Lets add data From a CSV file


Create a CSV file: The first Raw should be column Names

EG:

URL
User Name
Password
Alex
12345
KingJulien
45217
Marty
42597

Add the CSV file to a Folder Name data

Your File will look like this












Lets read from this csv File

Add a [DataSource] Tag Right Under the TestMethod and Add its Properties



Syantax:

 [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\Data\\datafile.csv", "datafile#csv", DataAccessMethod.Sequential), DeploymentItem("Data\\datafile.csv")]



Syntax Explained





You can use Excel, XML, SQL Database to enter data. Just change the data source as below

URL: https://msdn.microsoft.com/en-us/library/ms404700(VS.80).aspx











Comments

Popular posts from this blog

Drag and Drop with Telerik Testing Framework

Sheduling tests - Running Tests From the Command line | Telerik Testing Framework

Using page object model with Telerik Framework