Question: I am receiveing data from an API and adding the response to an arrayList (hero\_list)...as you can see that the request is made successfully in the first picture and the size of the arrayList is 117 (that's all the data).

[![enter image description here](https://i.stack.imgur.com/LXZ9h.jpg)](https://i.stack.imgur.com/LXZ9h.jpg)

But after exiting the call function the arrayList becomes empty

[![enter image description here](https://i.stack.imgur.com/pvXbo.jpg)](https://i.stack.imgur.com/pvXbo.jpg)

Answer: 
I faced the same situation when trying to use Sonar with Docker.

What worked for me was:

1. Make sure you have run your tests [You can use mvn test]
2. Make sure JaCoCo has generated the coverage report [In my case reports were generated in folder target\jacoco-report]
3. Set the following property pointing to your XML report

[Sonar property to be set](https://i.stack.imgur.com/AP2wY.png)
Sonarqube and sonar scanner do not provide tooling to generate code coverage reports. This should be done with tools like jacoco for java or opencover for .NET.

You can then add the output of jacoco to the sonar scanner with the `sonar.coverage.jacoco.xmlReportPaths` property.

so you will basically need the following steps for your analysis:

1. Sonar scanner begin
2. Restore packages
3. Build application
4. Use code coverage tool to test and calculate the coverage for your app
5. Sonar scanner end