Best way to setup Test with 10 Threads that firing API Request?

65 views Asked by At

I need to setup 1 test that spawns 10 Threads where each fires a request to the same REST Api. First I think it's not possbile to model real paralellism . In Java you cannot say thread1 should run on core1 and thread2 should run on core2 etc. But in Java it is possible to create Thread e.g. with fork/join framework or just with Runnable etc.

In our test scenario with 10 requests , 5 should return HTTP Status 200 and 5 should return 4xx HTTP Status so we know our locks etc works.

So should I just use Java native classes or Quarkus native classes or should I use a framwork like Gatlin which I have no idea of.

As I said it's just this 1 testcase and I ask myself if it's worth to burden our projekt with a new framework.

1

There are 1 answers

6
Koziołek On

You could use TestNG, that supports parallel and configurable tests:

@Test(threadPoolSize = 10, inmvocationCount=20, timeOut = 10000)
public void yourTest(){
  // …
}