Should I ignore unit tests for new constructors? Should I make a new Test class for the different constructors and just copy the tests? The tests themselves did not change. It would be nice if there was a way to run every test just with different constructors. To visualize what's going on, I added code below.
I had a class that looked like this:
public class Foo {
public Foo() {...}
public void doStuff(){...}
public void doThing(){...}
}
And I have a test class that looked like this:
public class FooTest {
Foo foo;
@Before
public void setUp() {
foo = new Foo();
}
@Test
public void fooCanDoThing() {
foo.doThing();
assertThat(...);
}
@Test
public void fooCanDoStuff() {
foo.doStuff();
assertThat(...);
}
}
I recently had a task that included adding more constructors to my foo class
public class Foo {
...
public Foo(String bleh) {...}
public Foo(String bleh, String blah) {...}
...
}
What is the best way to go about testing with multiple constructors?
Edit: To clear up some things, foo extends thing
public class Foo extends Thing {...}
Lets say that Thing has and handled function of getBlah
and I already tested for getBlah
. But now, I can actually set my own "blah."