инструментът cobertura причини неуспех на някои от моите тестове на Junit

Имам cobertrua 2.0.3 и Java 1.6.45 на linux OS 2.6.32.45-0.3-xen #1 SMP 2011-08-22 10:12:58 +0200 x86_64 x86_64 x86_64 GNU/Linux

Ако не инструментирам тези класове чрез изключване и тестовете на Junit работят добре. Докато инструментът включва тези класове и моите тестове на Junit ще се провалят.

Струваше ми се, че инструментът не е пълен или грешен само с някои от класовете ми, но не с всички.

====== стартирайте целеви инструмент ====

    <!--
                        Remove the coverage data file and any old instrumentation.
                -->
    <delete file="${basedir}/cobertura.ser" />
    <delete dir="${instrumented.dir}" />

    <!--
                        Instrument the application classes, writing the
                        instrumented classes into ${build.instrumented.dir}.
                -->
    <cobertura-instrument todir="${instrumented.dir}">
        <!--
                                The following line causes instrument to ignore any
                                source line containing a reference to log4j, for the
                                purposes of coverage reporting.
                        -->
        <ignore regex="org.apache.log4j.*" />

        <fileset dir="${classes.dir}">
            <!--
                                        Instrument all the application classes, but
                                        don't instrument the test classes.
                                -->
            <include name="**/*.class" />
            <exclude name="**/*Test*.class" />
            <exclude name="**/*HelloWorld*.class" />
            <exclude name="**/*Mock*.class" />
        </fileset>
    </cobertura-instrument>
</target>

Моят HelloWorld.java

    import java.io.IOException;
//import java.util.logging.FileHandler;
//import java.util.logging.Handler;
//import java.util.logging.Level;
import java.util.logging.Logger;


public class HelloWorld {

    private static final Logger LOGGER = Logger.getLogger(HelloWorld.class.getName());

    private String HELLO_WORLD = "Hello World";
    private String HELLO_SWEDEN = "Hello Sweden";
    private String message = "default message";

    public void printHello() throws SecurityException, IOException {
        LOGGER.entering(this.getClass().getName(), "Entering printHello()");
//      Handler fh = new FileHandler("%h/java%u.log");
//      fh.setLevel (Level.FINE);
//      LOGGER.addHandler(fh);
        setMessage(HELLO_WORLD);
        //System.out.println("From printHello():" + getMessage());
        LOGGER.info("message is: " + HELLO_WORLD);
        LOGGER.info("Print message:" + getMessage());

        LOGGER.finest("this is finest");
        LOGGER.finer("this is finer");
        LOGGER.fine("this is fine");
        LOGGER.config("this is config");
        LOGGER.info("this is info");
        LOGGER.warning("this is a warning");
        LOGGER.severe("this is severe");

        Trace.fine(this, "Trace fine print out");
        LOGGER.exiting(this.getClass().getName(), "Exiting printHello()");
    }

    public void printSweden() {

        setMessage(HELLO_SWEDEN);
        System.out.println("From printSweden():" +getMessage());
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}

person kingwang    schedule 18.08.2014    source източник
comment
Каква грешка получавате? Това може да ви помогне: stackoverflow.com/questions/18084436/   -  person Chris K    schedule 18.08.2014
comment
Използвам java 1.6.45 и само с ant Junit not maven project. Ако инструментирам HelloWorld.class, моят JUnit тест TestHelloWorld ще се провали. Проблемът със сигурност е в инструментирания *.class...но не знам как да го реша, имам нужда от помощ между другото моята мравка е 1.9.2 ========== Трябва да получа цялото покритие отчет не частично резултат от покритие на някои класове===== Моите тестове на Junit работят добре в eclipse с плъгин ecobertura....   -  person kingwang    schedule 18.08.2014
comment
Между другото, ecobertura при eclipse luna ми работи добре. Трябва обаче да стартирам командния ред за покритие на код в cobertura с ant.   -  person kingwang    schedule 27.02.2015