Hi,
thanks for the reply!
A solution would ofcourse be to copy the folder "Standard Icons" to the
directory where VSTestHost.exe is located. I though find it strange that
microsoft have not thought about this problem. It must be a common problem
for many developers out there. I had hoped that there would be a more
generic way of solving the problem then to copy files in an post build
script.
/Patrik
> Hi Patrik,
>
[quoted text clipped - 18 lines]
> Linda Liu
> Microsoft Online Community Support
Linda Liu[MSFT] - 25 Oct 2007 11:13 GMT
Hi Patrik,
Thank you for your feedback!
I understand your concern. I am performing more research on this issue and
will get the result abck to you ASAP.
I appreciate your patience!
Sincerely,
Linda Liu
Microsoft Online Community Support
Linda Liu[MSFT] - 26 Oct 2007 09:14 GMT
Hi Patrik,
After doing some more research, I found the solution.
The test engine runs tests not in the folder in which you have created or
generated them, but in a separate deployment folder. The deployment folder
can be local or remote. Remote test deployment occurs when you work with
controllers and agents.
For local test deployment, test engine copies deployment items, both files
and folders, to a folder on your computer before it runs tests.
There're several ways to deploy files or folders to the deployment folder.
You may refer to the following MSDN document on how to configure Test
Deployment:
'How to: Configure Test Deployment'
http://msdn2.microsoft.com/en-us/library/ms182475(vs.80).aspx
In your scenario, you can deploy the folder 'StandardIcons' to the
subdirectory named 'StandardIcons' of the deployment root directory. To do
this, you have two options.
Option 1: through run configuration
1. Follow the steps in the section 'To select files or folders to deploy,
in run configuration' in the above MSDN document to deploy the folder
'StandardIcons' to the deployment root directory.
2. Right-click the <run config file name>.testrunconfig in the Solution
Explorer and choose Open With. In the Open With dialog, choose 'XML Editor'
and click OK button.
3. In the <run config file name>.testrunconfig file, navigate to the tag
'<deploymentItems>' and add the 'StandardIcons' in the tag
'<outputDirectory>'. For example:
<deploymentItems
type="Microsoft.VisualStudio.TestTools.Common.DeploymentItemCollection">
<m_container type="System.Collections.Hashtable">
<key type="Microsoft.VisualStudio.TestTools.Common.DeploymentItem">
<path type="System.String">TestProject1\StandardIcons\</path>
<outputDirectory
type="System.String">StandardIcons</outputDirectory>
</key>
<value />
</m_container>
</deploymentItems>
Option 2: through the DeploymentItemAttribute
1. Copy the folder 'StandardIcons' under the test project folder.
2. Follow the steps in section 'To deploy items for a single test using the
DeploymentItem attribute' in the above MSDN document.
3. You need specify the second parameter for the DeploymentItemAttribute
constructor, for example:
[TestMethod()]
[DeploymentItem("TestProject1\\StandardIcons","StandardIcons")]
public void MyTestMethod()
{....}
After you deploy the entire directory of 'StandardIcons' to the deployment
root folder, you you can access the directory 'StandardIcons' directly in
the test method. For example:
[TestMethod()]
[DeploymentItem("TestProject1\\StandardIcons","StandardIcons")]
public void MyTestMethod()
{
Form1 target = new Form1();
// pass the file path to the method to test
actual = target.ReadFile("StandardIcons\\MyText.txt");
}
Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support