可以用junit进行压力测试吗?
我是 java 和 Junit 的新手,我需要对一组 Web 服务进行压力测试,现在对于每个 Web 服务我都有一个这样的测试:
@Test
public void webServiceTest() {
Integer firstParameter=0;
Integer secondParameter=9;
List<GeoArea> sampleList = kitDAO.myWebServiceToTest(firstParameter, secondParameter);
Assert.assertNotNull(sampleList);
Assert.assertTrue(sampleList.size() > 0);
}
有没有办法使用不同的参数同时调用此测试 100 次?我将创建 100 个线程,向它们传递 100 个不同的参数集并同时启动线程。你认为这可能吗?你会怎么做?
谢谢
I'm new to java and Junit, I need to stress test a set of web services, now for each web service I have a test like this:
@Test
public void webServiceTest() {
Integer firstParameter=0;
Integer secondParameter=9;
List<GeoArea> sampleList = kitDAO.myWebServiceToTest(firstParameter, secondParameter);
Assert.assertNotNull(sampleList);
Assert.assertTrue(sampleList.size() > 0);
}
Is there a way to call this test 100 time simultaneously with different parameters? I would create 100 thread, pass to them 100 different set of parameters and start the thread simultaneously. Do you think this is possible? How would you do it?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JUnitPerf 提供了一个 LoadTest 包装器来多次运行相同的测试。我不认为你可以向它传递不同的参数,但你可以自己添加该部分。拥有 100 个参数的静态列表,然后让测试的每个实例从该静态列表中删除一个值。
JUnitPerf provides a LoadTest wrapper to run the same test multiple times. I don't think you can pass it different parameters, but you could add that part yourself. Have a static list of your 100 parameters and then have each instance of the test remove one value from that static list.