If you’ve been using Scoverage with SBT to get some code coverage on your Scala code, you may come across an error while trying to run a main class on instrumentation turned on:

java.lang.NoClassDefFoundError: scoverage/Invoker$

This is quite puzzling as the tests run fine. I came across a possible Github issue while hunting around for a solution. It sounds like there is a runtime dependency on Scoverage classes.

One way to overcome this issue, is to turn off coverage when running your main class through SBT:


If you’re running SBT externally you can use:

sbt clean coverageOff run

When you want your coverage back on for your tests, you can use:


Or externally:

sbt clean coverage test

@alexflav23 recommends turning off coverage when publishing or packaging:

You need to disable coverage with coverageOff before publishing or packaging and everything will be just fine. I’ve ran into this issue myself and that was the quick fix.