Soru source directory for a DeploymentItem

  • 10 Ekim 2011 Pazartesi 23:12
     
     
    Is there any way for a test method to determine the location (file path) from which a deployment item was copied?

Tüm Yanıtlar

  • 11 Ekim 2011 Salı 02: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/
  • 11 Ekim 2011 Salı 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

  • 10 Nisan 2012 Salı 01:27
     
     
    Any thoughts? Anyone? Thanks!
  • 14 Nisan 2012 Cumartesi 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.

  • 16 Nisan 2012 Pazartesi 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.

  • 28 Haziran 2012 Perşembe 02:32
     
     
    Any additional suggestions? I think I could achieve the desired result just by getting the full path to the source files: .sln, .vsmdi, .csproj...