Hi Omar,

please consider these kind of annotations as a workaround. JaCoCo is not 
designed to have manual tagging.

The reason for this behaviour is that the lambda body will be compiled in 
another method which cannot be annotated. As another workaround you can extract 
the body to another (annotated) method and use a method reference to it.

Cheers,
-marc


> On 12. Oct 2023, at 11:32, Omar Al-Haj Qasem <[email protected]> wrote:
> 
> Thanks for the reply.
> When I tried that using annotation for a function that has no Lambda 
> expression it worked fine, but when there is a lambda expression inside the 
> candidate function it does not filter the whole function; only the first 
> lines that are not part of the lambda expression.
> Is there a way to exclude the whole function or exclude the lambda expression 
> inside a function?
> 
>  @ExcludeFromJacocoGeneratedReport
>  public void handleArrivedNotifications{
> 
> final Authentication auth = 
> SecurityContextHolder.getContext().getAuthentication();
>         logger.info("received order to send emails:");
>         
>        // lambda expression not excluded
>         CompletableFuture.runAsync(() -> {
>             try {
>                 // body
>             } catch (Exception e) {
>                 logger.error(e.getMessage(), e);
>             }
>         });
> 
> }
> 
> Best,
> Omar
> 
> On Monday, October 9, 2023 at 7:55:09 PM UTC+3 Marc Hoffmann wrote:
> Hi,
> 
> this is not possible. You may extract the code to its own method.
> 
> Regards,
> -marc
> 
> 
>> On 9. Oct 2023, at 13:33, Omar Al-Haj Qasem <[email protected] 
>> <applewebdata://798E8591-7576-4FEE-BC8F-C9D6D4799D20>> wrote:
>> 
> 
>> I need to exclude code block from code covarge, not just execlude function 
>> or class.
>> for example, when to exclude if starement or else branch from coverage.
>> Is that possible? if not, is there some kind of work around to do so?
>> 
>> Thanks
>> Omar
>> 
> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "JaCoCo and EclEmma Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] 
>> <applewebdata://798E8591-7576-4FEE-BC8F-C9D6D4799D20>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jacoco/ad190671-52ff-4397-9cd9-41c0533ece6bn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jacoco/ad190671-52ff-4397-9cd9-41c0533ece6bn%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "JaCoCo and EclEmma Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jacoco/8537822e-e4c2-4463-815d-3dc168a99a93n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jacoco/8537822e-e4c2-4463-815d-3dc168a99a93n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"JaCoCo and EclEmma Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jacoco/63C5ABEC-D9E2-49DB-AD54-927A24F8788F%40mountainminds.com.

Reply via email to