1

首先,很棒的图书馆!

如果我编译,然后在我验证它仍然在它编译的位置查找 *.approved.txt 时移动程序集,在我的情况下它不再存在。

我在 Teamcity 上遇到了这个问题,我们在不同的任务中构建和测试。因此,构建步骤将在 c:\BuildAgent\SomeGuid...

[Fact]
public void ShouldCreateCorrectOutgoingFiles() {
    var textToVerfiy = "Here's some text To Verify";
    Approvals.Verify(textToVerfiy);
}

...

: System.IO.DirectoryNotFoundException : Could not find a part of the path 'r:\w\254cbbd5ec9b56bc\project\ScenarioTests\myTests'.
Stack Trace:
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
   at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
   at System.IO.Directory.CreateDirectory(String path)
   at ApprovalTests.ApprovalTextWriter.WriteReceivedFile(String received)
   at ApprovalTests.Approvers.FileApprover.Approve()
   at ApprovalTests.Core.Approvals.Verify(IApprovalApprover approver, IApprovalFailureReporter reporter)
   at ApprovalTests.Approvals.Verify(IApprovalWriter writer, IApprovalNamer namer, IApprovalFailureReporter reporter)
   at ApprovalTests.Approvals.Verify(IApprovalWriter writer)
   at ApprovalTests.Approvals.Verify(String text)

关于如何调整它以在相对目录中查找可执行文件的任何想法。

4

1 回答 1

1

您必须编写一个自定义命名器。这很容易。看看这些文件。

http://bit.ly/IApprovalNamer

http://bit.ly/XUnitStackTraceParser

http://bit.ly/AttributeStackTraceParser

完成此操作后,您必须注册名称以供使用,只需调用即可。

Approvals.RegisterDefaultNamerCreation(()=> new MyCustomNamer());
于 2012-10-10T13:23:44.790 回答