We have a Spring project and functional tests (Testng framework) in the same project, but in a non-Spring module, so that there is no coupling between the project and tests.
Is there any way to calculate code coverage while running functional tests?
You would need to instrument your AUT (Application Under Test) using a tool such as JaCoCo. You then go ahead and deploy the instrumented build of your AUT in your test environment, run your functional tests against the instrumented build and then extract the code coverage report from the instrumented build.
I found a tutorial which can be referred to. See here (or) here for more information.
I have purposefully not duplicated the contents of any of the above blogs because the content would be too verbose.