Skip to content
Advertisement

JUnit instantiating object every time a test case method runs

Test case:

JavaScript

Class called from JUnit test case.

JavaScript

In my test case I only create the object once:

JavaScript

But internally JUnit calls the constructor three times.

Why is this happening?

Advertisement

Answer

You could create the pendingUtil in a @BeforeClass method.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement