Using EMMA for checking code coverage

Last edited on

The EMMA code coverage tool can be used with Squish for Java to check the code coverage of the Squish tests of Java applications.

However, because EMMA writes its coverage information upon shutdown of the JVM that executes the Java application it is important that the Squish test scripts closes the Java application normally.

If you let your test script end without closing the application first, Squish will kill the JVM process, and the coverage information will not be saved by EMMA.

Additionally, to avoid that Squish test script executions ends before the application has completely quit, be sure to insert waitFor() and snooze() statements at the end of the test script. The snooze time should be large enough for some safety. (Of course you could also check the process list for whether the process is still there, too.)

So eventually the script should be somewhat similar to this:

def main()
    ctx = startApplication("my_java_app")

    # Do some stuff

    # Script code for quitting the application

    # Wait for application context of our application
    # to claim that the application is not hook/running
    # anymore:

    # In addition, snooze to make sure test script ends
    # only after the application has really quit; adjust
    # snooze time to how long your application requires
    # to quit: