Ive written some Integration Tests (using XUnit) to test SmtpClient
. Basically I'm overriding it within my app.config
configuration>
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="F:\EmailTests\"/>
</smtp>
</mailSettings>
</system.net>
</configuration>
Now obviously this test fails on Team Services because of the following ref:
E:\EmailTests
Also this override doesn't except relative paths.
How should these scenarios be handled in TFS where I need to save data during a build?
You need to make the EmailTests
folder a part of your Unit Test project in Visual Studio, with the Copy Local
property set to True
. Doing so provides you with two options:
Since the folder is already part of your code-base, it will be checked out by VSO before beginning the build. Then if you need to access it in one of the build tasks, you can use the predefined build variable Build.SourcesDirectory
and combine it with your folder name like below. You can also use this within your configuration file, replacing the hard-coded F:\EmailTests\
.
$(Build.SourcesDirectory)\EmailTests\
Alternatively, you can access this folder using yet another VSO predefined variable Build.BinariesDirectory
. However, this will be useful only when the build of the Unit Test project has been completed.
Here is a link of all the predefined VSO variables for similar problems.