首先,伟大的图书馆!
如果我编译,那么当我验证它仍然在编译它的位置查找* .approved.txt时移动程序集,在我的情况下不再存在。
我在Teamcity上遇到了这个问题,我们在单独的任务中构建和测试。 所以构建步骤将构建在c:\ BuildAgent \ SomeGuid ... 我从构建中获取工件并在c:\ BuildAgent \ SomeOtherGuid中运行测试... 这失败,因为Approvals.Verify仍引用“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)
关于我如何调整它以查看相对目录到可执行文件的任何想法。
答案 0 :(得分:1)
您必须编写自定义名称。这很容易。看看这些文件。
http://bit.ly/XUnitStackTraceParser
http://bit.ly/AttributeStackTraceParser
一旦你这样做,你就必须注册名字才能使用,只需要打电话。
Approvals.RegisterDefaultNamerCreation(()=> new MyCustomNamer());