I have a Repo containing three solutions. Each solution has multiple projects, many of which are shared (including test projects).
I have a build pipeline along the following lines
- Retrieve NuGet packages
- Build Solution 1
- Build Solution 2
- Build Solution 3
- Execute all tests
The step to execute all tests is as follows:
- task: VSTest@2
displayName: 'Test'
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\*test*.dll
!**\*TestAdapter.dll
!**\obj\**
searchFolder: '$(System.DefaultWorkingDirectory)'
The vast majority of tests run perfectly. However, I get the odd and rather confusing error message for some tests:
[error]SetUp failed for test fixture TestProjectOne.A.B.GetSomethingTests
[error]SetUp : System.IO.DirectoryNotFoundException : Could not find a part of the path 'd:\a\1\s\Projects\TestProjectTwo\A\B\TestData\SomeFile.txt'.
So it's currently processing TestProjectOne but then saying it can't find a file under a path for TestProjectTwo.
The code within the test is as follows:
private const string RelativePath = @"..\..\A\B\TestData\";
...
var x = File.ReadAllText(RelativePath + "SomeFile.txt")
Needless to say, this works perfectly using Visual Studio 2019 using both the Visual Studio and ReSharper test runner.
Why would an Azure DevOps pipeline suffer this issue?