Say I have a class
public class Foo extends Bar
{
public Response post()
{
return authorize();
}
// override some additional methods from Bar class
}
and another class
public class Bar
{
public Response get()
{
return authorize();
}
public Response post()
{
return authorize();
}
public Response authorize()
{
// let's assume this method is "complicated" and has 200+ lines of code... lots of diff code paths etc
}
}
So I was thinking of a few different approaches in terms of unit testing
I directly call
authorizeand test every single possible code path. Then I write 1 happy path unit test for thegetandpostmethods forFooandBarfor completeness.I directly call
getandpostmethods of both classes, and decide to only write tests for all combinations against one method only.I completely ignore my
getandpostmethods and assume that as long as I fully test myauthorizemethod I'm good.
Am I complicating this? What's the best practice here.