Hi all,
As (almost) all of us can see,
Almost ;)
Running BLL tests both takes considerable time, and also we have to
take
class loading dependencies between classes with static methods when
we
use mockStatic - IMHO, this is kinda frustrating.
Maybe we should start get rid of PowerMock.
+ 1
PowerMock is the root of all evil...
Seriously, it costs more than it's worth..
Here is what I'm thinking of -
Currently, as we use no IoC for DAOs , for tested class we do not use
DbFacade.getInstance().getXXXDao()
instead we define:
protected XXXDao getXXXDao() {
return DBFacade.getInstance().getXXXDao();
}
And then in our tests we use Mockito to define how getXXDao acts in
the
test.
The following can be achieved also for config values , the following
way -
protected <T> T getConfig(ConfigValues key) {
return Config.<T> GetValue(key);
}
And then in code (for example, in a query test) -
doReturn(5).when(query).<Integer>
getConfig(any(ConfigValues.SomeIntegerConstant));
This is true for all static calls that do something other than 'util' stuff.
That is, if the static call is accessing DB or VDSM then it can be defined in a protected
method that will be mocked out when spying.
However I (obviously) don't see any use mocking out calls such as Arrays.asList(...).
This effort can be done in small steps -
a. Define getConfig method in base classes (i.e AuditLoggalbeBase).
I would put it in command bases, since this doesn't have anything to do with logging.
b. Rewrite parts (i.e Commands, and their tests) step by step (small
commits)
Thoughts and ideas are more than welcome,
Yair
_______________________________________________
Engine-devel mailing list
Engine-devel(a)ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-devel