How to include data xml file

4 posts, 0 answers
  1. Michael
    Michael avatar
    21 posts
    Member since:
    Apr 2013

    Posted 28 Jun 2013 Link to this post

    I have to run a test in which i use a xml file which gives me the information about the 
    expected data on the page.
    At the moment i find the xml document via an fixed path name.

    This is an example in code:
      string xmlFile =@"C:\Users\\Documents\Test Studio Projects\myproject\mydata.xml";
                Assert.IsTrue(File.Exists(xmlFile), String.Format ("Configuration file {0} not found", xmlFile));
                using (StreamReader xmlReader = new StreamReader(xmlFile, Encoding.GetEncoding("iso-8859-1"))) 

    This works fine on my local development environment, but the test has to be executed on an external scheduling server.
    How can i include this xml in the test project, so that it is correctly included on the scheduling server?
    Thanks for help?
    Michael
  2. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 02 Jul 2013 Link to this post

    Hello Michael,

    The easiest and fastest way to achieve this since you are using fixed path is to put the xml file to a shared location which will be accessible from all the computers you are executing the test on, including your local computer.

    Regards,
    Ivaylo
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  3. Michael
    Michael avatar
    21 posts
    Member since:
    Apr 2013

    Posted 05 Jul 2013 Link to this post

    Hello Ivaylo ,

    thanks for your answer. Is there an alternative instead of using a fixed path?
    I could put it in the bin-folder of course, but how do  ihave to include it in the project so that the xml is
    correctly transferred to the bin-folder?
  4. Ivaylo
    Admin
    Ivaylo avatar
    750 posts

    Posted 09 Jul 2013 Link to this post

    Hello Michael,

    As I noticed the best practice in such cases is to put the file on a remote location.
    The other way you can proceed is to use relative path instead of full path and put the file in question in the project's folder. If you decide to do it this way copy the file in the project's folder and replace your line of code:

    string xmlFile =@"C:\Users\\Documents\Test Studio Projects\myproject\mydata.xml";

    with:

    string xmlFile = this.ExecutionContext.DeploymentDirectory + "\\mydata.xml";

    Regards,
    Ivaylo
    Telerik
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top