2010-01-27 1 views
3

Je cours la cible de couverture de code:couverture de code zéro avec cobertura 1.9.2, mais les tests fonctionnent

<junit fork="yes" dir="${basedir}" failureProperty="test.failed"> 
     <!-- 
         Note the classpath order: instrumented classes are before the 
         original (uninstrumented) classes. This is important. 
       --> 
     <classpath path="${instrumented.dir}" /> 
     <classpath path="${classes.dir}" /> 
     <classpath refid="classpath" /> 
     <!-- 
         The instrumented classes reference classes used by the 
         Cobertura runtime, so Cobertura and its dependencies 
         must be on your classpath. 
       --> 
     <classpath refid="cobertura.classpath" /> 

     <formatter type="xml" /> 
     <!--<test name="${testcase}" todir="${reports.xml.dir}" if="testcase" />--> 
     <batchtest fork="yes" todir="${reports.xml.dir}"> 
       <fileset dir="${classes.dir}"> 
         <include name="**/generated/AllTests.class" /> 
       </fileset> 
     </batchtest> 
</junit> 

<junitreport todir="${reports.xml.dir}"> 
     <fileset dir="${reports.xml.dir}"> 
       <include name="TEST-*.xml" /> 
     </fileset> 
     <report format="frames" todir="${reports.html.dir}" /> 
</junitreport> 

Puis-je obtenir la sortie suivante (en utilisant la fourchette = "true"):

java.lang.reflect.InvocationTargetException 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
     at java.lang.reflect.Method.invoke(Method.java:585) 
     at net.sourceforge.cobertura.util.FileLocker.lock(FileLocker.java:124) 
     at net.sourceforge.cobertura.coveragedata.ProjectData.saveGlobalProjectData(ProjectData.java:331) 
     at net.sourceforge.cobertura.coveragedata.SaveTimer.run(SaveTimer.java:31) 
     at java.lang.Thread.run(Thread.java:595) 
Caused by: java.io.IOException: No locks available 
     at sun.nio.ch.FileChannelImpl.lock0(Native Method) 
     at sun.nio.ch.FileChannelImpl.lock(FileChannelImpl.java:784) 
     at java.nio.channels.FileChannel.lock(FileChannel.java:865) 
     ... 8 more 
--------------------------------------- 
Unable to get lock on /vobs/rnc/rrt/roam2/roamSs/RoamMao_swb/RoamMao_bldu/ant_build/cobertura.ser.lock: null 
This is known to happen on Linux kernel 2.6.20. 
Make sure cobertura.jar is in the root classpath of the jvm 
process running the instrumented code. If the instrumented code 
is running in a web server, this means cobertura.jar should be in 
the web server's lib directory. 
Don't put multiple copies of cobertura.jar in different WEB-INF/lib directories. 
Only one classloader should load cobertura. It should be the root classloader. 

J'utilise Ant 1.7.0 et cobertura 1.9.2.

Des idées pour lesquelles il n'y a pas de couverture? Le test fonctionne bien comme je le vois dans ma cible. J'ai essayé de changer les versions java (1.5.0_06 et 1.6.0_10) mais pas de différence.

Répondre

0

Votre cobertura se bloque au milieu de la construction.

Vous pouvez essayer de mettre à niveau Cobertura vers la version 1.9.3 ou 1.9.4.1. J'ai eu quelques problèmes avec 1.9.4.1, cependant, et j'utilise actuellement 1.9.3.

5

J'ai trouvé le succès dans la définition de la propriété d'environnement cobertura.use.java.nio=false.

Depuis que j'utilisais fourmi, je vient de modifier le fichier cobertura-build.xml en ajoutant ce qui suit à la commande <junit>:

<junit fork="yes"> 
    <jvmarg value="-Dcobertura.use.java.nio=false"/> 
    ... 
</junit> 
+0

Réglage cobertura.use.java.nio = false aussi résolu ce problème pour moi. –

Questions connexes