0

I know that for me to create a data driven test that i need to use a datasource with the test method, and that the datasource had to have already existed.

My question is how about if you want to make a test method data driven but you don't have the datasource file at run time.

Edit What i mean is I want to basically iterate over the same test X number of times. The reason I dont have the data is because i have to first fetch the data first and then iterate over it.

below i created a test that ran for each of my hyperlink but after the test pass i only get results Passed Once instead for each iteration of my hyperlink. I also tried to launch something in the "[TestInitialize()]" section and assign my data file to it but since the data file has to be constant(or already exist), i cant do it. Any help with this would be great

    [TestMethod]
    public void Verify_Rates_Links()
    {
         HomePage getLinks = new HomePage(GlobalVariable.Browser);
         int PicCount = 0;
        // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
        PageObjects.Shared.SharedBetweenPage StarTest = new PageObjects.Shared.SharedBetweenPage(GlobalVariable.Browser);
        getLinks.GetAllHeaderLinks("Rates", "3", GlobalVariable.Rates_Links);           
        foreach ( HtmlHyperlink links in GlobalVariable.Rates_Links)
        {
        Assert.IsTrue(
            StarTest.LetsGoToHomePage()
            .LetsclickLink(links)
            .VerifyLocationPage("Rates","Rates", "Rates", "VerifyRateslinkBreadcrumb" + PicCount.ToString() + ".jpg", "VerifyRatesHeader" + PicCount.ToString() + ".jpg"),
            "There is an issue with Rates to create new membership APP one or more of the work flows is not work");
        //Playback.Cleanup();
            //testcl
        PicCount++;
        }



    }

~Will

skinnyWill
  • 327
  • 2
  • 18
  • 1
    If the data source is not available at runtime then how do you plan to get the data to datadrive the test? Please [edit] the question to explain what you are trying to achieve. – AdrianHHH Dec 02 '15 at 19:44
  • Related http://stackoverflow.com/questions/23469100/how-to-run-a-test-many-times-with-data-read-from-csv-file-data-driving – AdrianHHH Dec 02 '15 at 19:45
  • Again, what are you trying to achieve. What does *"have to first fetch the data"* mean and where is any of that shown in the code. I think this question may be too broad according to [help/on-topic]. – AdrianHHH Dec 03 '15 at 12:48
  • Use [a Test Case in TFS](https://msdn.microsoft.com/en-us/library/ee624082.aspx) if you need to do it at run time. – lloyd Dec 06 '15 at 22:10

0 Answers0