Skip to content
Advertisement

junit- sonarQube test coverage : if condition

can you help me how I can cover if statement by junit test in this method:

This is my Method in the controller “User” :

JavaScript

My problem is with the 2 lines of the if statment, I don’t know how i want to cover them.

This is my test code for this method :

JavaScript

Thank you in advance for your help

Advertisement

Answer

You need to create a temporary Authentication information

JavaScript

Result: Sonar coverage

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement