Its because your class contain only 11 lines :)

Thanks,
Krishantha.

On Wed, Jun 3, 2015 at 12:25 PM, Gihan Anuruddha <[email protected]> wrote:

> Hi Krishantha,
>
> I covered the areas that I need to test in that class. But due to that
> private constructor, code coverage percentage affects drastically :(
>
> Regards,
> Gihan
>
> On Wed, Jun 3, 2015 at 12:16 PM, Krishantha Samaraweera <
> [email protected]> wrote:
>
>> Hi Gihan,
>>
>> I think you are writing integration test to cover the case. If it is the
>> case, generating coverage for empty private method is not possible. There
>> is a bug reported in Emma to skip the empty private constructors [1].
>>
>> If it is a unit test, you can use java reflection to call private method
>> [2]. However it is arguable to invoke private constructor which should
>> never be called. My recommendation is not to cover the private constructor,
>> in coverage POV it doesn't add much value to numbers as the method contain
>> only 2 lines.
>>
>> Thanks,
>> Krishantha.
>>
>> [1]http://sourceforge.net/p/emma/bugs/66/
>> [2]
>> http://stackoverflow.com/questions/19699634/coverage-for-private-constructor-junit-emma
>>
>> On Wed, Jun 3, 2015 at 12:01 PM, Gihan Anuruddha <[email protected]> wrote:
>>
>>> Hi Saneth,
>>>
>>> No. We are only using static methods in that class. So there is no need
>>> to call that private method. That was only added as suggest by sonar.
>>>
>>> Regards,
>>> Gihan
>>>
>>> On Wed, Jun 3, 2015 at 11:58 AM, Saneth Dharmakeerthi <[email protected]>
>>> wrote:
>>>
>>>> Hi Gihan,
>>>>
>>>> Isn't that private constructor is get called by anywhere inside that
>>>> class?.
>>>>
>>>>
>>>> Thanks and Best Regards,
>>>>
>>>> Saneth Dharmakeerthi
>>>> Senior Software Engineer
>>>> WSO2, Inc.
>>>> Mobile: +94772325511
>>>>
>>>> On Wed, Jun 3, 2015 at 11:47 AM, Gihan Anuruddha <[email protected]>
>>>> wrote:
>>>>
>>>>> Hi Automation team,
>>>>>
>>>>> What we are actually looking as a code coverage stat?  In my
>>>>> ServiceHolder class, I added private constructor based on sonar
>>>>> suggestion. Now, due to that I can't make my class, 100% code coverage in
>>>>> term of line, block and method. How do I overcome this problem and 
>>>>> increase
>>>>> my code coverage percentage?
>>>>>
>>>>> COVERAGE SUMMARY FOR SOURCE FILE [ServiceHolder.java]nameline, %
>>>>> block, %method, %class, %ServiceHolder.java82%  (9/11)83%  (15/18)
>>>>> 86%  (6/7)100% (1/1)COVERAGE BREAKDOWN BY CLASS AND METHODnameline, %
>>>>> block, %method, %class, %     class ServiceHolder82%  (9/11)
>>>>> 83%  (15/18)86%  (6/7)100% (1/1)
>>>>> getAnalyticsDataService (): AnalyticsDataService100% (1/1)100% (2/2)
>>>>> 100% (1/1) getAnalyticsEventSinkService (): AnalyticsEventSinkService
>>>>> 100% (1/1)100% (2/2)100% (1/1)
>>>>> getEventStreamService (): EventStreamService100% (1/1)100% (2/2)
>>>>> 100% (1/1) setAnalyticsDataService (AnalyticsDataService): void
>>>>> 100% (2/2)100% (3/3)100% (1/1)
>>>>> setAnalyticsEventSinkService (AnalyticsEventSinkService): void
>>>>> 100% (2/2)100% (3/3)100% (1/1)
>>>>> setEventStreamService (EventStreamService): void100% (2/2)100% (3/3)
>>>>> 100% (1/1) ServiceHolder (): void0%   (0/2)0%   (0/3)0%   (0/1)
>>>>>
>>>>>
>>>>>
>>>>> ​Regards,
>>>>> Gihan​
>>>>>
>>>>> --
>>>>> W.G. Gihan Anuruddha
>>>>> Senior Software Engineer | WSO2, Inc.
>>>>> M: +94772272595
>>>>>
>>>>> _______________________________________________
>>>>> Dev mailing list
>>>>> [email protected]
>>>>> http://wso2.org/cgi-bin/mailman/listinfo/dev
>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> W.G. Gihan Anuruddha
>>> Senior Software Engineer | WSO2, Inc.
>>> M: +94772272595
>>>
>>
>>
>>
>> --
>> Krishantha Samaraweera
>> Senior Technical Lead - Test Automation
>> Mobile: +94 77 7759918
>> WSO2, Inc.; http://wso2.com/
>> lean . enterprise . middlewear.
>>
>
>
>
> --
> W.G. Gihan Anuruddha
> Senior Software Engineer | WSO2, Inc.
> M: +94772272595
>



-- 
Krishantha Samaraweera
Senior Technical Lead - Test Automation
Mobile: +94 77 7759918
WSO2, Inc.; http://wso2.com/
lean . enterprise . middlewear.
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to