JUnit 4 PermGen size overflow when running tests in Eclipse and Maven2

Viewed 18716

I'm doing some unit tests with JUnit, PowerMock and Mockito. I have a lot of test classes annotated with @RunWith(PowerMockRunner.class) and @PrepareForTest(SomeClassesNames) to mock final classes and more than 200 test cases.

Recently I've run into a problem of a PermGen space overflow when I run my entire test suite in Eclipse or Maven2. When I run my test one by one then each of them succeeds.

I did some research about that, however none of the advice helped me (I have increased PermGenSize and MaxPermSize). Recently I've found out that there is one class that contains only static methods and each method returns object mocked with PowerMockito. I'm wondering whether it is a good practice and maybe this is the origin of the problem because static variables are being shared between unit tests?

Generally speaking is it a good practice to have a static class with a lot of static methods which returns static mocked objects?

3 Answers
Related