VerifyTests/Verify

Wrong verified files path on Azure DevOps build agents

majkelllo opened this issue · 4 comments

The tests works great locally, however, after running them on Private Azure DevOps build agents, the tests are failing.
The tests are failing because somehow the .received. files are generated in wrong directory.
We are running tests using standard dotnet test {PATH_TO_CSPROJ}, without any custom config / arguments

The SourceCode path ( containing verified files ) is:
C:\agent_work\17\s\MyService.UnitTests\Approvals

While somehow the framework puts .received. files in:
C:\s\MyService.UnitTests\Approvals

This is really strange, is there some magic environment variable that is used by the Framework to determine where to put the .received. files ? ( C:\s\ is not a directory used by Azure DevOps, it is created by VerifyTests framework somehow )

are you using custom code to put your files in “/Approvals”?

Yes I am using following code:

var settings = new VerifySettings();
settings.UseDirectory("Approvals");
settings.UseFileName("ValidCsproj");
await Verify(solutionFileContent.Projects[0].Content, settings);

I have also tried with simple UseFileName:

await Verify(solutionFileContent.Projects[0].Content).UseFileName("VisualStudioCodeGeneratorTests.ValidCsproj");

Unfortunately the result is the same.

i suspect it because UseDirectory leverages the current directory. and that is different in devops

try this

    public static class ModuleInitializer
    {
        [ModuleInitializer]
        public static void Init() =>
            Verifier.UseProjectRelativeDirectory("Approvals");
    }

@SimonCropp I have just tried this method - it worked like a charm. Many thanks for quick help ! Issue resolved