This is a migrated thread and some comments may be shown as answers.

How to include data xml file

3 Answers 70 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 28 Jun 2013, 11:23 AM
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

3 Answers, 1 is accepted

Sort by
0
Ivaylo
Telerik team
answered on 02 Jul 2013, 11:51 AM
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
0
Michael
Top achievements
Rank 1
answered on 05 Jul 2013, 12:07 PM
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?
0
Ivaylo
Telerik team
answered on 09 Jul 2013, 04:03 PM
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
Tags
General Discussions
Asked by
Michael
Top achievements
Rank 1
Answers by
Ivaylo
Telerik team
Michael
Top achievements
Rank 1
Share this question
or