我想知道是否可以运行基于xUnit的性能测试?
答案 0 :(得分:5)
不确定您究竟要求的是什么,但您可以轻松编写自己的自定义属性来执行此操作。举个例子..
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public class TraceAttribute : BeforeAfterTestAttribute
{
public override void Before(MethodInfo methodUnderTest)
{
//Start timer
}
public override void After(MethodInfo methodUnderTest)
{
//End timer
}
}
然后用this属性装饰你的单元测试。还要确保写入输出;)
答案 1 :(得分:0)
对于JUnit,您可以查看JUnitPerf。
如果你使用不同的语言和不同的xUnit,JunitPerf设计概念(装饰正常的JUnit测试)和代码可能会提供如何用你的语言做同样的想法。
答案 2 :(得分:0)
现在在Github上有一个项目:https://github.com/Microsoft/xunit-performance
它在xUnit上提供了扩展,以进行作者的性能测试(基准)。