使用 xUnit 框架进行性能测试

发布于 2024-09-06 06:58:07 字数 29 浏览 3 评论 0原文

我想知道是否可以基于xUnit进行性能测试?

I wonder if it is possible to run performance testing based on xUnit?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

冧九 2024-09-13 06:58:08

不确定您到底要问什么,但您可以轻松编写自己的自定义属性来做到这一点。举个例子......

[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 属性装饰你的单元测试。还要确保写入输出;)

Not sure what exactly you asking, but you can easily write your own custom attribute to do that. For an example..

[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
    }
}

Then decorate your Unit Test with the this attribute. Also make sure you write to an output ;)

記憶穿過時間隧道 2024-09-13 06:58:08

对于 JUnit,您可以查看 JUnitPerf

如果您使用不同的语言和不同的 xUnit,JunitPerf 设计概念(装饰正常的 JUnit 测试)和代码可能会提供如何在您的语言中执行相同操作的想法。

For JUnit, you might look at JUnitPerf.

If you're working in a different language and a different xUnit, the JunitPerf design concept (decorating normal JUnit tests) and code might give ideas of how to do the same in your language.

有深☉意 2024-09-13 06:58:08

现在Github上有一个项目: https://github.com/Microsoft/xunit-performance

它提供了 xUnit 的扩展来编写性能测试(基准测试)。

Now there is a project on Github : https://github.com/Microsoft/xunit-performance

It provides extensions over xUnit to author performance tests (benchmark).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文