source directory for a DeploymentItem
-
lunes, 10 de octubre de 2011 23:12Is there any way for a test method to determine the location (file path) from which a deployment item was copied?
Todas las respuestas
-
martes, 11 de octubre de 2011 2:36
This is not an ideal solution but hope it does what you are looking for.
You can specify a DeploymentItem arribute on the TestMethod/TestClass and specify a static variable in its argument.
You can then use the same static variable in your testcase.
Thanks,
Anuj
http://www.anujchaudhary.com/ -
martes, 11 de octubre de 2011 16:34
Thank you for the reply. However, this strategy does not resolve my dilemma.
I have a DeploymentItem with a parameter like this: "..\..\..\a\b\foo.txt"
The file is correctly deployed to the test results directory and available to the test. However, I also need to get the path to where foo.txt came from originally.
The entire tree is moved to different machines at different root levels. I cannot hard code the absolute path to the source directory.
Note: I could solve my problem if I can figure out the absolute path to any part of the solution that contains the test source (e.g. path to .sln file).
Thanks.
Alex
-
martes, 10 de abril de 2012 1:27Any thoughts? Anyone? Thanks!
-
sábado, 14 de abril de 2012 20:30
Hi,
In case of local execution with default deployment settings and running tests from IDE test run directory is created as "<SolutionDirectory>\TestResults\<TestRunDirectory>". TestRunDirectory path can be accessed using TestContext.Properties["TestRunDirectory"]. Please check if this helps.
What is the dependency on source location ? Test should be independent of source location. Consider fixing this dependency instead of above approach (if that works).
Thanks.
-
lunes, 16 de abril de 2012 19:29
Thanks for the reply.
However, I already know how to use the test results directory. I use it for many things. I also know that it'd be better if I didn't need to know the source directory. However, the test I am trying to write has a reliance on stuff that's not deploy-able. I wish it were different. But, it's not.
So, I am try to figure out the test source or the solution source directory from inside the test.
Thanks.
-
jueves, 28 de junio de 2012 2:32Any additional suggestions? I think I could achieve the desired result just by getting the full path to the source files: .sln, .vsmdi, .csproj...

