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.

4

4 回答 4

1

Apache JMeter正是您想要的项目。您可以将它指向一个正在运行的进程,或者让它启动多个线程,每个线程都启动一个进程。它将监控吞吐量、错误率和您感兴趣的任何其他内容,并将其全部呈现在一组图表中。

于 2013-02-06T18:40:13.577 回答
0

看看 Metrics ( http://metrics.codahale.com/ )。您可以使用它来检测您的应用程序,并在测试套件运行甚至发布到指标服务器后获得有趣的报告。

于 2013-05-30T13:45:14.933 回答
0

假设您有一个 Java 类和一个 Test 方法,如下所示:

import org.junit.Test;

public class AnyTestEndPoint {

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

您的上述测试可以通过以下配置馈送到负载生成器。

您可以virtual-users从如下所示的简单properties配置文件中生成。

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

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

在上面的配置中,number.of.threads表示要同时增加的虚拟用户。

然后您的负载测试如下所示,指向上述内容Test

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

}

这可以针对JUnit4 负载生成JUnit5 负载生成来实现。请参阅 HelloWorld GitHub 存储库中的运行示例。

于 2020-05-25T10:28:54.040 回答
-1

你可以试试 JUnit 或 TestNG。我过去曾使用过它们。不确定它是否正是您要找的。

于 2013-02-06T18:38:58.360 回答