简体   繁体   English

在Eclipse 4.3中使用@ContextConfiguration和SpringJUnit4ClassRunner进行的春季测试似乎很慢

[英]Spring tests with @ContextConfiguration and SpringJUnit4ClassRunner in Eclipse 4.3 seem slow

I have a suite of 54 tests (a handful of which are properly integration that write some data to a mysql database and delete it). 我有一套54个测试(其中少数几个是正确集成的,可以将一些数据写入mysql数据库并删除)。 It takes 117 seconds to run my junit tests with the eclipse test runner. 用Eclipse TestRunner运行我的junit测试需要117秒。 I have another app with 244 tests in a similar mix that work with couch and these take 308 seconds. 我有另一个应用程序,其中244个测试以类似的方式与沙发配合使用,这些测试需要308秒。

A VS 2010 c# project with a similar mix of ~50 similar tests (using spring.net) runs in ~10 seconds. 带有约50个相似测试(使用spring.net)的相似混合的VS 2010 c#项目在约10秒内运行。

I also have a mocha node test suite with 260 tests (similar mix to the above) that takes 2 seconds to run. 我还有一个带有260个测试的Mocha节点测试套件(与上面的混合类似),需要2秒钟才能运行。

My understanding is that the application contexts loaded by ContextConfiguration are cached, so that shouldn't be an issue. 我的理解是,由ContextConfiguration加载的应用程序上下文已缓存,因此这不是问题。 I'm finding myself increasingly frustrated by the length of time it takes to run my java application tests. 我发现自己对运行Java应用程序测试所花费的时间越来越感到沮丧。

I guess I'm wondering whether 2 seconds per test is about what I should be expecting. 我想我想知道每次测试2秒是否符合我的期望。 Whether anything can be done to speed things up. 是否可以采取任何措施来加快速度。

Finally, if one can only hope to get some incremental improvements with junit and eclipse, I'm wondering how folks can stand it. 最后,如果仅希望通过junit和eclipse进行一些增量改进,我想知道人们如何接受它。

Make sure you don't use @DirtiesContext , this will cause context reloading per class or test. 确保不使用@DirtiesContext ,这将导致按类或测试重新加载上下文。 Also <beans default-lazy-init="true"> in your test context may help by initializing only the beans needed on the current test 同样,在您的测试上下文中, <beans default-lazy-init="true">可以通过仅初始化当前测试所需的Bean来提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM