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
authorize
and test every single possible code path. Then I write 1 happy path unit test for theget
andpost
methods forFoo
andBar
for completeness.I directly call
get
andpost
methods of both classes, and decide to only write tests for all combinations against one method only.I completely ignore my
get
andpost
methods and assume that as long as I fully test myauthorize
method I'm good.
Am I complicating this? What's the best practice here.