Problem description I have the following test class with a few tests. The setUp() method executes insert statements from a file. The first test simply makes a post request and expects an array of JSON objects in return with a 200(OK) status: Upon running the first test I get the following error: What I Tried …
Tag: mockmvc
JUnit4 failed to load application context
I am trying to use JUnit4 for testing of my project. I have tried using JUnit5 but I cannot get this working either. I am trying to test my account controller at the momemnt. This is the full stack trace of the error I am receving Here is my build.gradle: } This is the version of spring boot I am
How to ignore a method call inside a method that is being tested?
I am trying to make a test pass with mockmvc and it is failing with the following error message: Caused by: org.apache.kafka.common.config.ConfigException We have Kafka in our service layer as a dependency, and it is being called inside the method we are testing. Is there a way to ignore that specific call du…
No mapping for request with mockmvc
Currently struggling with problem when I get ‘mapping error for request’ with following controller/test configuration. Controller: Test: Configuration: After test execution I get No mapping for POST /subscriber/session The reason for the struggle is that my code from other modules with the same co…
Get size of json from MvcResult
I’m testing an API and get all data from the DB. I save the response as I get a json as response. I want to get the length of json array. So, if I have 2 rows in DB, I want to get 2 as a result. Or is there maybe another way to count number of rows which are