添加一个运行多个VS版本的新单元测试后,我收到此错误:
vstest.executionengine.x86.exe已停止工作
在弹出窗口中.
我正在使用审批测试.在我的开发机器上DiffReporter
,当我的测试结果与批准的不同时,我很高兴开始使用TortoiseDiff:
[UseReporter(typeof (DiffReporter))]
public class MyApprovalTests
{ ... }
Run Code Online (Sandbox Code Playgroud)
但是,当在Teamcity上运行相同的测试并且结果不同时,测试将失败,并显示以下错误:
System.Exception : Unable to launch: tortoisemerge.exe with arguments ...
Error Message: The system cannot find the file specified
---- System.ComponentModel.Win32Exception : The system cannot find the file
specified
Run Code Online (Sandbox Code Playgroud)
显然它找不到tortoisemerge.exe,这很好,因为它没有安装在构建代理上.但是如果它被安装了怎么办?然后对于每个失败,另一个tortoisemerge.exe实例将启动,没有人会关闭它.最终吨的tortoisemerge.exe实例将杀死我们的服务器:)
所以问题是 - 如何修改测试以在本地机器上运行Tortoise Diff并仅在构建服务器上报告错误?我知道 #IF DEBUG [UseReporter(typeof (DiffReporter))]
但如果可能的话会更喜欢另一种解决方案.
我无法找到如何移动.approved.在Approval-tests中将文件发送到自己的文件夹.我猜信息就在某处 - 我找不到它.
当我尝试使用带有[Theory]
属性的单元测试批准时,它说:
System.Exception: System.Exception : Approvals is not set up to use your test framework.
It currently supports [NUnit, MsTest, MbUnit, xUnit.net]
To add one use ApprovalTests.StackTraceParsers.StackTraceParser.AddParser() method to add implementation of ApprovalTests.StackTraceParsers.IStackTraceParser with support for your testing framework.
To learn how to implement one see http://blog.approvaltests.com/2012/01/creating-namers.html
at ApprovalTests.StackTraceParsers.StackTraceParser.Parse(StackTrace stackTrace)
at ApprovalTests.Namers.UnitTestFrameworkNamer..ctor()
at ApprovalTests.Approvals.GetDefaultNamer()
at ApprovalTests.Approvals.Verify(IApprovalWriter writer)
at ApprovalTests.Approvals.Verify(Object text)
Run Code Online (Sandbox Code Playgroud)
似乎它只识别[Fact]
属性.我试图关注stacktrace中的链接, 但没有关于如何将自己的名称/解析器插入批准的内容.
有没有我可以添加自己的名字/解析器的入口点?它本身似乎微不足道,唯一的问题是如何使用它:
public class TheoryNamer : AttributeStackTraceParser
{
protected override string GetAttributeType()
{ …
Run Code Online (Sandbox Code Playgroud) 我可以将ApprovalTests与PDF一起使用吗?我尝试使用FileLauncher,但似乎相同的PDF在文件(位)级别略有不同.或者我错误地使用了它?
[TestMethod]
[UseReporter(typeof(FileLauncherReporter))]
public void TestPdf()
{
var createSomePdf = PdfCreate();
ApprovalTests.Approvals.Verify(new FileInfo(createSomePdf.FileName));
}
Run Code Online (Sandbox Code Playgroud) 是什么原因导致出现“批准未设置为使用您的测试框架。”的消息?
我们有一个基于 ApprovalTests 的单元测试,该测试在夜间远程团队构建中失败,但存在以下异常:
该单元测试在本地 VS2010 单元测试运行(即 mstest)中顺利通过。它在远程团队“签入”构建(每次代码签入时运行)中也能顺利通过。
我们在测试开始时记录了一些诊断信息,以识别正在运行的 ApprovalTests.dll 程序集...
--------------------
ApprovalTests, Version=1.21.4657.21485, Culture=neutral, PublicKeyToken=11bd7d124fc62e0f:
CodeBase = file:///E:/BldSrc/27/305/TestResults/NightlyBuild/Client[2]/Out/ApprovalTests.DLL
FullName = ApprovalTests, Version=1.21.4657.21485, Culture=neutral, PublicKeyToken=11bd7d124fc62e0f
GlobalAssemblyCache = False
ImageRuntimeVersion = v4.0.30319
Location = E:\BldSrc\27\305\TestResults\NightlyBuild\Client[2]\Out\ApprovalTests.dll
Company Name =
Assembly Product = ApprovalTests
--------------------
Run Code Online (Sandbox Code Playgroud)
这是堆栈跟踪...
ApprovalTests.StackTraceParsers.StackTraceParser.Parse(StackTrace stackTrace)
ApprovalTests.Namers.UnitTestFrameworkNamer..ctor()
ApprovalTests.Approvals.<.cctor>b__11()
ApprovalTests.Approvals.GetDefaultNamer()
ApprovalTests.Approvals.Verify(IApprovalWriter writer)
ApprovalTests.Approvals.Verify(String text)
ApprovalTests.Combinations.CombinationApprovals.VerifyAllCombinations[A,B,C,D,E,F,G,H,I](Func`10 processCall, String format, Func`2 resultFormatter, IEnumerable`1 aList, IEnumerable`1 bList, IEnumerable`1 cList, IEnumerable`1 dList, IEnumerable`1 …
Run Code Online (Sandbox Code Playgroud) 当我运行批准测试时,批准测试的一些调试输出会进入我的日志.看起来像
2/15/2016 1:58:48 PM ~000002ms Variable: approvalFrame = ''
2/15/2016 1:58:48 PM ~000025ms Variable: approvalFrame = ''
2/15/2016 1:58:48 PM ~000003ms Variable: approvalFrame = ''
2/15/2016 1:58:48 PM ~000002ms Variable: approvalFrame = '......
有没有办法将其隐藏在日志中?
谢谢.
我正在尝试使用Approval-Tests但是甚至无法运行"Hello World".当我运行测试时,我得到了
Test Name: TestHelloWorld
Test FullName: HelloApprovalTests.Class1.TestHelloWorld
Test Source: C:\Users\Lassi\Documents\Visual Studio 2015\Projects\HelloApprovalTests\HelloApprovalTests\Class1.cs : line 14
Test Outcome: Failed
Test Duration: 0:00:00.01
Result StackTrace:
at ApprovalTests.Namers.UnitTestFrameworkNamer..ctor()
at ApprovalTests.Approvals.<.cctor>b__c()
at ApprovalTests.Approvals.GetDefaultNamer()
at ApprovalTests.Approvals.Verify(IApprovalWriter writer)
at ApprovalTests.Approvals.Verify(String text)
at HelloApprovalTests.Class1.TestHelloWorld() in C:\Users\Lassi\Documents\Visual Studio 2015\Projects\HelloApprovalTests\HelloApprovalTests\Class1.cs:line 15
Result Message: System.MissingMethodException : Method not found: 'System.Diagnostics.StackTrace ApprovalUtilities.CallStack.Caller.get_StackTrace()'.
Run Code Online (Sandbox Code Playgroud)
我的班级是:
using ApprovalTests;
using ApprovalTests.Reporters;
using NUnit.Framework;
namespace HelloApprovalTests
{
[TestFixture]
[UseReporter(typeof(DiffReporter))]
public class Class1
{
[Test]
public void TestHelloWorld()
{
Approvals.Verify("Hello World Welcome to ApprovalTests");
}
} …
Run Code Online (Sandbox Code Playgroud) 我想在循环中运行批准测试,以便我可以测试100-1000s的XML文件.我让序列化器输出到一个字符串,然后在Verify()调用中使用它.
但是,我希望能够将verify方法设置为每个测试使用不同的文件名.类和方法名称很好,但是我想用附加名称标记它来描述数据库中正在测试的记录的ID.
这有可能,如果是这样的话怎么样?例如
MyTests.Test_X.ID101.approved.txt
MyTests.Test_X.ID101.received.txt
我有一个方法生成一些图像(1.jpg,2.jpg ...)将它们写入文件系统.我想用ApprovalTest验证此方法的结果.问题是Approvals.verify(image)
将收到和批准的文件命名为测试方法.因此,我无法通过一次测试验证多个图像.
如何在一次测试中验证多个图像?
approval-tests ×10
unit-testing ×6
c# ×5
.net ×4
java ×1
teamcity ×1
testing ×1
tfsbuild ×1
xunit.net ×1