Help the world stop coronavirus! Stay home!

Prev Next

JUnit / Junit Interview questions III

When are unit tests garbage collected in Junit?

As per the design, the Test instances tree is built at first pass and the test execution is performed as the second pass.

The test runner holds strong references to all test instances for the duration of the test execution. For instance, in case of a very long test run with many Test instances, none of the tests may be garbage collected until the completion of the entire test run.

Therefore, we need to programmatically free-up resources that are availed or allocated for running a test.. Explicitly setting an object to null in the tearDown() method allows it to be garbage collected before the completion of the entire test run.

❤Cash Back At Stores you Love !!!❤

Earn your $10 reward when you make your first purchase through Ebates by signing up with clicking below button.

Ebates Coupons and Cash Back

More Related questions...

Show more question and Answers...

TOSCA

Comments & Discussions