First start by creating a Test Case in Microsoft Test Manager. In the test case outline the simple steps that your automation will be following. Example:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6PjwCA81I9H30rvwhdq-sLlBZLrMPFuRrfeBBhiAAnd9hrZem2wkM1MsT4rNypqfvbEjVHHcn2mEfK61oladvJj3RB3NYfmqbCifMP5QIEI2BDflHeyFglezWkagbP3KJ0dHXAhlhKQY/s400/TestCaseSetUp.png)
Notice in the above image I have identified each of the steps in my test. I have also identified the parameters I am going to use for my testing, and the validating parameters needed to assert if the test passes or fails. The parameters are preceded with an @ symbol in the steps section, and for each parameter identified in the steps section, there is a correlating column in the parameter section of the test case. In this section I have put in all of the different variations that I want to test for. In this example I am testing a search function which has 3 different filters Age, Gender, Ethnicity, and also a search text box. I am testing each of the different fields by running through a series of tests.
Now that the test case has all of the parameters, and scenarios identified we now create the automation needed to run the scenarios. When creating the automation you will need to have the following.
1. Make sure your test class is using the using the reference Microsoft.VisualStudio.TestTools.UnitTesting.
2. Instantiate an instance of TestContext. Example:
2. On or with your [TestMethod] add a DataSource() attribute. Template:
Example:
3. Call the parameters from the test case into your method using TestContext.DataRow[].ToString();
For example:
Now that the test case has all of the parameters, and scenarios identified we now create the automation needed to run the scenarios. When creating the automation you will need to have the following.
1. Make sure your test class is using the using the reference Microsoft.VisualStudio.TestTools.UnitTesting.
2. Instantiate an instance of TestContext. Example:
private TestContext m_testContext;
public TestContext TestContext
{
get { return m_testContext; }
set { m_testContext = value; }
}
2. On or with your [TestMethod] add a DataSource() attribute. Template:
[TestMethod]
[DataSource( "Microsoft.VisualStudio.TestTools.DataSource.TestCase", "; ", " ", Microsoft.VisualStudio.TestTools.UnitTesting.DataAccessMethod.Sequential)]
Example:
[TestMethod]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.TestCase",
"http://icstfs.blogspot.org:8080/tfs/blogspot;Quality Management","77300",
Microsoft.VisualStudio.TestTools.UnitTesting.DataAccessMethod.Sequential)]
3. Call the parameters from the test case into your method using TestContext.DataRow[
For example:
public void SearchPerson()
{
string gender = TestContext.DataRow["Gender"].ToString();
string age = TestContext.DataRow["Age"].ToString();
string ethnicity = TestContext.DataRow["Ethnicity"].ToString();
string searchText = TestContext.DataRow["SearchText"].ToString();
string validPerson = TestContext.DataRow["ValidPerson"].ToString();
string invalidPerson = TestContext.DataRow["InvalidPerson"].ToString();
string validDescription = TestContext.DataRow["ValidDescription"].ToString();
if(!_meetMormonFilter.IsMeetMormonsVisible())
{
_menu.GoToHome(); //If Meet Mormon wigit isn't visible go to home page }
}
_meetMormonFilter.FindPeople(gender, age, ethnicity, searchText); //Find a person using the wigit
_peopleSearchResults.ViewByListClick(); //View the search to list to see names and descriptions
Assert.IsTrue(_peopleSearchResults.ListFinderHasPerson(validPerson),"Person: "+validPerson+" Not found in grid"); //Check person name is in grid
Assert.IsFalse(_peopleSearchResults.ListFinderHasPerson(invalidPerson),"Person: "+invalidPerson+" Is found in grid and should not be"); //Check a invalid person is not in grid
string description = _peopleSearchResults.GetProfilDescription(validPerson); //Get Description associated with Valid User
Assert.IsTrue(description.Contains(validDescription), "Description for Person: " + validPerson + " did not contain phrase: "+validDescription);//Check that description contains the text stored in Valid Description
_peopleSearchResults.ListFinderSelectProfile(validPerson); //Go to the User Profile
}
Finally with the automation linked to the test case, visual studio will run the test once for each row of parameters that you have. After the test is done running you will see one test that has failed or passed in the Test Result. However if you double click on the test result, you will be able to see all of the tests ran.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQk_QxPG538z8W22FZaAPfIXDIbJ42kNuPlfOwExfGpfcgdFGnII3l_Ase0AQEaynoEFiBNb5uU2z3KcA36LaE1b9E-Eb6vpPBp85rdIZuCtMGMR9ZWmSoCB8RHnBsLFopdXJIQd6tB9U/s400/TestResults.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQk_QxPG538z8W22FZaAPfIXDIbJ42kNuPlfOwExfGpfcgdFGnII3l_Ase0AQEaynoEFiBNb5uU2z3KcA36LaE1b9E-Eb6vpPBp85rdIZuCtMGMR9ZWmSoCB8RHnBsLFopdXJIQd6tB9U/s400/TestResults.png)
Wow, What a Excellent post. I really found this to much informatics. It is what i was searching for.I would like to suggest you that please keep sharing such type of info.Visit here for Penetration testing services and Software testing services
ReplyDelete