If I write test that sets up a Mock in a method annotated with @BeforeMethod, that mock is correctly torn down after the method completes. However, if I change the annotation to @BeforeClass, that mock is not correctly torn down. I think that this is because the TestNGRunnerDecorator does not implement the ITestListener interface and tear down mocks after the class finishes.
So in summary, the following works as expected:
@BeforeMethod
public void setup() {
new MockThatExtendsMockUp();
}
But the following does not:
@BeforeClass
public void setup() {
new MockThatExtendsMockUp();
}