So I have junit tests, let's pretend this is my code:
@Test
public void test1() {
Object o = new Object("123");
AssertTrue(o.string == "123");
}
@Test
public void test2() {
Object o = new Object("456");
AssertTrue(o.string == "456");
}
Let's pretend the code has a public string field that appends an argument to that string. Now test1 returns true, because it's "123", but test2 returns false because it's "123456", which means Object o still exists when test 2 executes. I didn't have any problems doing tests in Junit before, but now my object's string just accumulates for each test.
Aren't objects supposed to be automatically destroyed when a java method finishes execution? Can I force an object to be deleted?
Thanks.