Coverage tool: no longer finds class file within jar. #220

Closed
wknorr opened this Issue Oct 20, 2015 · 2 comments

Projects

None yet

2 participants

@wknorr
wknorr commented Oct 20, 2015

Summary
I get the following error when trying to get coverage information for a test application when the classes are in a jar file when using jmockit-coverage 1.19:

JMockit: No classes were instrumented for coverage; please make sure that classes selected for coverage through the regular expression "com.qhrtech.emr.qa.*" are available from the runtime classpath, and that they have been compiled with debug information.

The information is correctly generated when I use jmockit-coverage 1.16 or other earlier versions.
It is also correctly generated if I have the class files outside the jar.

The application simply prints a message and waits for the user to press enter.

Steps to reproduce:

  1. Compile the project: "mvn install".
  2. Run the application from the command line with the following command:
    "C:\Program Files\Java\jdk1.8.0_60\bin\java.exe" -classpath ./target/TestApp-1.0-SNAPSHOT.jar -javaagent:./target/runtimejars/jmockit-coverage.jar -Dcoverage-outputDir=./CodeCoverageReports -Dcoverage-classes=com.qhrtech.emr.qa.* -Dcoverage-metrics=line -Dcoverage-output=html-nocp com.qhrtech.emr.qa.testapp.TestApp
  3. While the application is waiting for the user, attempt to generate code coverage information:
  • Open jconsole.
  • Connect to com.qhrtech.emr.testapp.TestApp .
  • Go to the MBeans tab.
  • Select JMockit Coverage->Coverage Control->Operations->generateOutput.
  • Click the generateOutput button.
    Results
    In the command window, the "No classes instrumented..." message is printed.

No output files are created in the output directory, CodeCoverageReports.

Versions
jmockit-coverage: 1.19 (from the Maven central repository)
Maven: 3.3.3
Java: JDK 1.8.0 u60

Source code:
===== src/main/java/com/qhrtech/emr/qa/testapp/TestApp.java =====

package com.qhrtech.emr.qa.testapp;

import java.util.Scanner;

public class TestApp {

    public static void main( String[] args ) {

        System.out.println( "Press enter." );
        Scanner keyboard = new Scanner( System.in );
        keyboard.nextLine();

    }

}

=====pom.xm=====

<?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.qhrtech.emr.qa</groupId>
    <artifactId>TestApp</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>org.jmockit</groupId>
            <artifactId>jmockit-coverage</artifactId>
            <version>1.19</version>
            <type>jar</type>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>
                <executions>
                    <execution>
                        <id>copy-jars</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/runtimejars</outputDirectory>
                            <overWriteReleases>true</overWriteReleases>
                            <overWriteSnapshots>true</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                            <includeScope>runtime</includeScope>
                            <includeTypes>jar</includeTypes>
                            <stripVersion>true</stripVersion>
                            <stripClassifier>true</stripClassifier>
                            <useRepositoryLayout>false</useRepositoryLayout>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
@rliesenfeld rliesenfeld added the bug label Oct 21, 2015
@rliesenfeld rliesenfeld self-assigned this Oct 21, 2015
@wknorr
wknorr commented Oct 26, 2015

Thanks for working on this.

I updated my pom file to bring in jmockit-coverage version 1.20 from the Maven Central Repository, which looks like it has your fix, but I still get the same error.

From: Rogério Liesenfeld [mailto:notifications@github.com]
Sent: Friday, October 23, 2015 6:16 PM
To: jmockit/jmockit1 jmockit1@noreply.github.com
Cc: Wayne Knorr wayne.knorr@QHRtech.com
Subject: Re: [jmockit1] Coverage tool: no longer finds class file within jar. (#220)

Closed #220#220 via a718931a718931.


Reply to this email directly or view it on GitHubhttps://github.com/jmockit/jmockit1/issues/220#event-444373813.

@rliesenfeld
Member

A bug related to classes from jars was fixed, but there was another one. Issue #229 was open for it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment