Verify icon indicating copy to clipboard operation
Verify copied to clipboard

Using VS remote test environment results in System.ArgumentNullException : Value cannot be null. (Parameter 'directory')

Open edumserrano opened this issue 2 years ago • 2 comments

Description

Verify throws System.ArgumentNullException : Value cannot be null. (Parameter 'directory') when trying to run tests in Visual Studio on Windows using remote test environment targeting Ubuntu-20.04 via WSL2.

How to reproduce

  1. Create a new xUnit test project.
  2. Setup a remote test environment using WLS2.
  3. Create a test that uses Verify.
  4. Run the test.
  5. Test fails with System.ArgumentNullException : Value cannot be null. (Parameter 'directory') exception.

Unless this is not something you are willing to support, I would expect that instead of the exception I would get the usual Verify flow generating received files and comparing them with verified files.

System

This happens when using the following NuGet package versions:

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="Verify.Xunit" Version="17.10.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="Verify.Xunit" Version="17.10.2" />

in the following system:

.NET SDK (reflecting any global.json):
 Version:   6.0.400
 Commit:    7771abd614

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.400\

More info

I also tested using the latest Verify pre-release version: 18.0.0-beta.18. It should be straightforward to reproduce this issue using the steps outlined above but if it helps, I could create a repo to reproduce this.

testenvironments.json

This was the test environment file I used:

{
  "version": "1",
  "environments": [
    {
      "name": "WSL-Ubuntu-20.04",
      "type": "wsl",
      "wslDistribution": "Ubuntu-20.04"
    }
  ]
}

Verify 17.10.2 exception stack trace

  Message: 
    System.ArgumentNullException : Value cannot be null. (Parameter 'directory')

  Stack Trace: 
    Guard.AgainstEmpty(String value, String argumentName) line 99
    Guard.BadDirectoryName(String name, String argumentName) line 50
    PathInfo.ctor(String directory, String typeName, String methodName) line 15
    <.cctor>b__42_2(String sourceFile, String projectDirectory, Type type, MethodInfo method) line 23
    VerifierSettings.GetPathInfo(String sourceFile, Type type, MethodInfo method) line 29
    ReflectionFileNameBuilder.FileNamePrefix(MethodInfo method, Type type, String sourceFile, VerifySettings settings, String uniquenessForReceived, String uniquenessForVerified) line 11
    <>c__DisplayClass0_0.<GetVerifier>b__0(String uniquenessForReceived, String uniquenessForVerified) line 16
    InnerVerifier.ctor(String sourceFile, VerifySettings settings, GetFileConvention fileConvention) line 17
    Verifier.GetVerifier(VerifySettings settings, String sourceFile) line 12
    <<Verify>b__0>d.MoveNext() line 30
    --- End of stack trace from previous location ---
    ReadDataFromDifferentGitHubWorkflowCommandDependencyErrorTests.FailedHttpToDownloadArtifact() line 102
    --- End of stack trace from previous location ---

Verify 18.0.0-beta.18 exception stack trace

  Message: 
    System.ArgumentNullException : Value cannot be null. (Parameter 'directory')

  Stack Trace: 
    Guard.AgainstEmpty(String value, String argumentName) line 108
    Guard.BadDirectoryName(String name, String argumentName) line 59
    PathInfo.ctor(String directory, String typeName, String methodName) line 15
    <.cctor>b__26_0(String sourceFile, String projectDirectory, Type type, MethodInfo method) line 10
    Verifier.GetPathInfo(String sourceFile, Type type, MethodInfo method) line 18
    Verifier.GetVerifier(VerifySettings settings, String sourceFile, Boolean useUniqueDirectory) line 23
    <<Verify>b__0>d.MoveNext() line 63
    --- End of stack trace from previous location ---
    ReadDataFromDifferentGitHubWorkflowCommandDependencyErrorTests.FailedHttpToDownloadArtifact() line 102
    --- End of stack trace from previous location ---

edumserrano avatar Sep 18 '22 13:09 edumserrano

happy to support wsl. can u submit a PR that achieves this

SimonCropp avatar Sep 22 '22 13:09 SimonCropp

This one seems trickier than the issue with strict JSON I was able to debug but I can give it a try. If I figure it out I'll submit a PR.

edumserrano avatar Sep 25 '22 15:09 edumserrano

any update on a PR? or should i close this?

SimonCropp avatar Nov 20 '22 08:11 SimonCropp

Things got busy and I didn't manage to progress with this. Feel free to close.

edumserrano avatar Nov 21 '22 09:11 edumserrano