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.
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...