I’m using Karibu Testing for testing my Vaadin applications which work perfectly. But recently, I encountered a problem when I analyzed my code with n. Karibu Testing’s assertion methods are not recognized by SonarQube.
The Problem
The image below shows the problem:
As you can see, there is an _assert() method call, but SonarQube does not know about Karibu Testing.
By default, SonarQube knows these testing frameworks:
- AssertJ
- Awaitility
- EasyMock
- Eclipse Vert.x
- Fest 1.x and 2.x
- Hamcrest
- JMock
- JMockit
- JUnit
- Mockito
- Rest-assured 2.x, 3.x and 4.x
- RxJava 1.x and 2.x
- Selenide
- Spring’s
org.springframework.test.web.servlet.ResultActions.andExpect()
andorg.springframework.test.web.servlet.ResultActions.andExpectAll()
- Truth Framework
- WireMock
But how can we configure SonarQube to recognize Karibu Testing?
The Solution
The first thing to do is to create a custom Quality Profile. The easiest way is to copy one of the predefined profiles:

Then we need to configure rule S2699. Simply search for it in the rules view:

Then scroll down to Quality Profiles and hit “Change”:

There we have to configure the fully qualified method name. We can use wildcards to add all assert methods using com.github.mvysny.kaributesting.v10.LocatorJ#_assert*
After creating the Quality Profile we have to activate it on our project:


That’s it! When we analyze our project the next time the error is gone.