VB.Net: how can I get the source path of the assembly while running MSTest?
I'm trying to switch from NUnit to MSTest (for the Code Coverage option). We have some of the configuration for the application stored in files (the application finds them by using a relative path, starting from the "bin" folder, where the .dlls are). NUnit worked fine with this configuration. MSTest copies the .dlls in a test folder (TestResults/name/OUT). Is there any way to use MSTest and set it up so it won't copy the .dlls (execute them from the "bin" folder)? I've been searching for this option and it seems to be impossible. Another question (if the copy option is not configurabl开发者_开发百科e) how can I find out the starting .dll path (the original file path for the file that gets copied by MSTest in the OUT folder)?
Thanks
You can use one of the methods in the System.Reflection.Assembly class:
Assembly.GetExecutingAssembly()
Assembly.GetCallingAssembly()
Assembly.GetEntryAssembly()
Between those you should be able to get all you need.
You can also use TestContext. See http://msdn.microsoft.com/en-us/library/ms404699.aspx.
精彩评论