ApprovalTests.Net icon indicating copy to clipboard operation
ApprovalTests.Net copied to clipboard

.NET Core 3.1 with xUnit 2.4.1 - ApprovalTests is not detecting the proper source path

Open GregorBiswanger opened this issue 5 years ago • 2 comments

Hello,

I have created a new xUnit .NET Core 3.1 project with the ApprovalTests v.5.4.5 library, I always get the following exception:

 System.Exception : 
    ApprovalTests is not detecting the proper source path
    
    This is probably because you're missing the following
    line in your .csproj file:
    	  <DebugType>full</DebugType>
    in the
    <Project>
      <PropertyGroup>
    element.
    
    Solution:
    a) Add <DebugType>full</DebugType> to your .csproj file.
    b) OR Build->Advanced->DebugInfo to Full
  Stack Trace: 
    StackTraceParser.get_SourcePath() line 80
    UnitTestFrameworkNamer.get_SourcePath() line 28
    FileApprover.Approve() line 27
    Approver.Verify(IApprovalApprover approver, IApprovalFailureReporter reporter) line 7
    Approvals.Verify(IApprovalApprover approver, IApprovalFailureReporter reporter) line 71
    Approvals.Verify(IApprovalWriter writer, IApprovalNamer namer, IApprovalFailureReporter reporter) line 52
    Approvals.Verify(IApprovalWriter writer) line 124
    Approvals.VerifyWithExtension(String text, String fileExtensionWithDot, Func`2 scrubber) line 189
    Approvals.Verify(String text, Func`2 scrubber) line 176
    NameJoinerTests.JoinNames() line 19

I added the DebugType in the solution file. Unfortunately did not help.

That would be the unit test:

using ApprovalTests;
using ApprovalTests.Reporters;
using Xunit;

namespace ApprovalTestsSample
{
    public class NameJoinerTests
    {
        [Fact]
        [UseReporter(typeof(DiffReporter))]
        public void JoinNames()
        {
            var nameJoiner = new NameJoiner();

            string result = nameJoiner.Join("Gregor", "Biswanger");

            Approvals.Verify(result);
        }
    }
}

GregorBiswanger avatar Dec 11 '20 13:12 GregorBiswanger

Maybe same problem (and workaround) as with my open Issue: https://github.com/approvals/ApprovalTests.Net/issues/449

farangkao avatar Dec 13 '20 18:12 farangkao

This project is not being actively maintained. Instead consider using Verify. See Migrating from ApprovalTests for more information.

SimonCropp avatar Dec 24 '21 11:12 SimonCropp