I've got a method in a class that's writing to some string, which calls another method which does the same. Something like:
void foo() {
a += "xyx";
bar();
}
void bar() {
a += "abc";
}
For unit testing purposes, I want to test foo and bar separately. Is there any way to prevent bar from being run when I call foo() or to replace it with another method?
Create a subclass that overrides bar() that does nothing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With