noconnor / JUnitPerf

API performance testing framework built using JUnit
Apache License 2.0
68 stars 18 forks source link

Add support for JUnit 5 parameterized tests #120

Closed ILadis closed 4 months ago

ILadis commented 4 months ago

This pull request adds support for JUnit 5 parameterized tests.
With the proposed changes it is now possible to use @JUnitPerfTest on a @ParameterizedTest method.

Here's an example of how this can be used:

@ExtendWith(JUnitPerfInterceptor.class)
public class ExampleParameterizedTests {

    @ValueSource(strings = { "www.google.com", "www.example.com" })
    @ParameterizedTest(name = "test1(hostname = {0})")
    @JUnitPerfTest(durationMs = 3_000, maxExecutionsPerSecond = 1)
    public void test1(String hostname) throws IOException {
        try (Socket socket = new Socket()) {
            socket.connect(new InetSocketAddress(hostname, 80), 1000);
        }
    }

}

I'm open for any feedback.