Java SpringBoot || Writing Test cases for Code Coverage || JUnit || Mockito

Rahul Kapoor 21 Reputation points


Brief info about class under Test.
The class will fetch secret, certificate and access token from KeyVault and Also using Corbertura as code coverage tool.
I am trying to write testcases (using Junit, Mockito) for the below classes, but unable to find correct way.


Some problems I found is as the above classes are marked as final, so unable to Mock. Also if I try to use PowerMock, Corbertura doesnt detect the code covered by it.

Please suggest any alternative way of testing so that my code coverage also gets calculated using corbertura.


Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
711 questions
Azure App Services
Azure App Services
A feature of Azure App Service used to create and deploy scalable, mission-critical web apps.
4,599 questions
Azure Active Directory
Azure Active Directory
An Azure enterprise identity service that provides single sign-on and multi-factor authentication.
13,659 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Alfredo Revilla (MSFT) 17,096 Reputation points Microsoft Employee

    Hello, you should not need to mock implementations but interfaces, such as IConfidentialClientApplication (implemented by ConfidentialClientApplication). To make your classes (unit) testable you should inject interfaces as dependencies.

    Please let me know if you need more help. If the answer was helpful to you, please accept it and, optionally, provide feedback so that other members in the community can benefit from it.