Search code examples
javajarcode-coverageemma

How to use emma for jar files


How do I run use emma with a jar file. I downloaded emma.jar and another jar for testing purpose (MySQLConnector.jar). I placed both the jars in the same folder and tried to give this command

java -cp emma.jar emmarun -jar MySQLConnector.jar

. But I got an error saying

emmarun: failed to load Main-Class manifest attribute from

[C:\Documetings\Administrator\Desktop\jars\mysql-connector-java-5.0.8-bin.jar]

How do I solve this problem!!.. ANy other methods to test code coverage are also welcome!!

Thanks in advance!!


Solution

  • We only can instrument executable jars. Which makes sense: emma needs something to run. And the connector library simply isn't executable: it's manifest file does not have the Main-Class attribute and I guess, the library does not contain a class with a main method too.

    Rethink what you really want to test. The coverage report will show which lines of code have been executed during a (test) run. It does not tell us, which lines are executable.

    Find yourself an executable jar and then you should see valid result.