Want to write articles/new answer to be published in javapedia.net? Send in your article with your name to javatutorials2016@gmail.com!

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.

Invest now!!! Get Free equity stock!

Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.

The Robinhood app makes it easy to trade stocks, crypto and more.

More Related questions...

Show more question and Answers...


Comments & Discussions