I\'m wondering if there is a way to specify that a method gets called in advance of a class method. I know something like this should be posssible, since JUnit has before(),
I assume that the problem here is as follows:
init()
method that will finish construction.init()
will be called right after the constructor.My suggestion is to use a factory object or method. The simplest way is to make the constructor private, add a construct()
method with the parameters of the constructor or something of that sort, and then have the construct()
method both create the object and call init()
, then return it.