[Engine-devel] Getting rid of PowerMock?

Moti Asayag masayag at redhat.com
Wed Mar 28 09:11:04 UTC 2012


On 03/28/2012 09:23 AM, Laszlo Hornyak wrote:
> Hi,
> 
> How much faster could the unit tests run after removing powermock and using the instance methods instead?
> 

Major problem is the demand for forkMode=always to bypass the OOME.
Simple check of running SearchBackend unit-test without/with
forkMode=always shows 3s vs 7s, and for utils project 17s vs 65s.
I can only assume that for the backend project test time could be cut by
half.

> I like this idea anyway because it could be a step towards dependency injection.
> Could be a more motivating long term objective than just to get rid of powermock :)
> 
> Laszlo
> 
> ----- Original Message -----
>> From: "Yair Zaslavsky" <yzaslavs at redhat.com>
>> To: "engine-devel" <engine-devel at ovirt.org>
>> Sent: Tuesday, March 27, 2012 7:33:18 PM
>> Subject: [Engine-devel] Getting rid of PowerMock?
>>
>> Hi all,
>> As (almost) all of us can see,
>> 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.
>> 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 effort can be done in small steps -
>> a. Define getConfig method in base classes (i.e AuditLoggalbeBase).
>> 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 at ovirt.org
>> http://lists.ovirt.org/mailman/listinfo/engine-devel
>>
> _______________________________________________
> Engine-devel mailing list
> Engine-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/engine-devel




More information about the Devel mailing list