Performance Testing using xUnit framework
Asked Answered
F

3

12

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

Footsie answered 18/6, 2010 at 7:35 Comment(1)
Are you asking about the xUnit.net framework, or just any 'xUnit' framework (as defined by the book xUnit Test Patterns)?Hierarch
U
0

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.

Uraeus answered 12/5, 2011 at 11:12 Comment(1)
JUnitPerf is for Java. I need to test my C# codes. How one can test his/her C# code performance?Apennines
H
6

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 ;)

Hour answered 12/5, 2011 at 10:58 Comment(1)
for some cases it actually can help - but only for those, when a test run is LONG enough for the (highperf) timer to actually tick, and of course there are classic problems with concurrency and nondeterministic waits injected by the OS. real solution would at least run the given unit test ie. 100 times and measure he average speed. BUT, in xUnit, I currently do not know of any better way to measure the time than the one you have presented, and so there's a +1 for you :)Beardless
U
0

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.

Uraeus answered 12/5, 2011 at 11:12 Comment(1)
JUnitPerf is for Java. I need to test my C# codes. How one can test his/her C# code performance?Apennines
T
0

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

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

Thermophone answered 18/9, 2019 at 12:27 Comment(1)
> This repo has been archived, as this project is no longer maintained. We recommend that you use BenchmarkDotNet for your benchmarking needs.Mori

© 2022 - 2024 — McMap. All rights reserved.