1

Is there a load testing framework that I could use where I can supply my own Java class and test the performance of that class. So basically the framework would essentially spawn threads and record when those threads finished running and then generate a report with the final results.

Mike Christensen
  • 88,082
  • 50
  • 208
  • 326
Salil Surendran
  • 2,245
  • 4
  • 27
  • 42

4 Answers4

1

Apache JMeter is exactly the project you want. You can point it at a running process or have it spin up multiple threads each starting a process. It will monitor the throughput, error rate and anything else you are interested in and render it all in a set of charts.

Jason Sperske
  • 29,816
  • 8
  • 73
  • 124
0

Take a look into Metrics (http://metrics.codahale.com/). You can use it to instrument your app, and get interesting reports after a test suite run or even published to a metrics server.

rbajales
  • 1,010
  • 1
  • 9
  • 14
0

Assuming you have a Java Class and a Test method like below:

import org.junit.Test;

public class AnyTestEndPoint {

    @Test
    public void anyTestMethod() throws Exception {
       ...
       your code goes here for a single user
       ...
    }
}

Your above test can be fed to the load generator with following configs.

You can spawn virtual-users from a simple properties config file like below.

#  my_load_config.properties
#############################

number.of.threads=50
ramp.up.period.in.seconds=10
loop.count=1

In the above config, number.of.threads represents virtual users to be ramped up concurrently.

Then your load test looks like below which is pointing to the above Test:

@LoadWith("my_load_config.properties")
@TestMapping(testClass = AnyTestEndPoint.class, testMethod = "anyTestMethod")
@RunWith(ZeroCodeLoadRunner.class)
public class LoadTest {

}

This can be achieved for JUnit4 load generation and JUnit5 load generation. See the running examples in the HelloWorld GitHub repo.

-1

You could try JUnit or TestNG. I have used them in the past. Not sure if it exactly what you are looking for.

Rhys
  • 2,807
  • 8
  • 46
  • 68
  • JUnit and TestNG is not load testing framewok. – khanmizan Mar 12 '15 at 03:53
  • By using threadPoolSize and invocationCount, it's possible (and fast) to get some simple load tests running on TestNG. You do have to do your instrumentation yourself, though. – Azuaron Mar 24 '16 at 18:54