EdwinLi / powermock

Automatically exported from code.google.com/p/powermock
0 stars 0 forks source link

PowerMock doesn't work correctly when using cobertura and Maven #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There seems to be a problem with cobertura, Maven and PowerMock.

For example adding cobertura to the DocumentationExamples project results
in the following error message (on Linux as well after configuring surefire
with cobertura.use.java.nio to false): 

Cobertura: Loaded information on 5 classes.
Cobertura: Coverage data file
/home/johan/devtools/java/projects/powermock/examples/DocumentationExamples/targ
et/cobertura/cobertura.ser
either does not exist or is not readable.  Creating a new data file.
Cobertura: Error reading file
/home/johan/devtools/java/projects/powermock/examples/DocumentationExamples/targ
et/cobertura/cobertura.ser:
null
Cobertura: Saved information on 1 classes.
Cobertura: Error reading file
/home/johan/devtools/java/projects/powermock/examples/DocumentationExamples/targ
et/cobertura/cobertura.ser:
null
Cobertura: Coverage data file
/home/johan/devtools/java/projects/powermock/examples/DocumentationExamples/targ
et/cobertura/cobertura.ser
either does not exist or is not readable.  Creating a new data file.
Cobertura: Saved information on 5 classes.
Cobertura: Saved information on 1 classes.
[INFO] [cobertura:cobertura]
[INFO] Cobertura 1.9 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Cobertura: Loaded information on 1 classes.
[cobertura] INFO  [main]
net.sourceforge.cobertura.reporting.html.HTMLReport - Data file does not
contain instrumentation information for the file
powermock/examples/staticmocking/ServiceRegistrator.java.  Ensure this
class was instrumented, and this data file contains the instrumentation
information.
Report time: 119ms

We need to address this if possible.

Original issue reported on code.google.com by johan.ha...@gmail.com on 1 Oct 2008 at 7:13

GoogleCodeExporter commented 9 years ago
There seems to be a work-around: 
  <build>
  <plugins>
     <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <forkMode>pertest</forkMode> 
        </configuration>
      </plugin>
     </plugins>
  </build>

Original comment by johan.ha...@gmail.com on 1 Oct 2008 at 9:54

GoogleCodeExporter commented 9 years ago

Original comment by jan.kron...@gmail.com on 16 Oct 2008 at 5:32

GoogleCodeExporter commented 9 years ago
The workaround is good enough for now

Original comment by johan.ha...@gmail.com on 17 Nov 2008 at 12:30

GoogleCodeExporter commented 9 years ago
I don't think workaround is good enough. With the work around, I still get the
Unable to get lock on
/home/h_maf/hudson/data/jobs/mplus-services-applications/workspace/mplus_service
s/applications/routing/ServiceEndpointRouter/target/cobertura/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.

Original comment by rohit.c.joshi@gmail.com on 3 Aug 2009 at 8:31

GoogleCodeExporter commented 9 years ago
The workaround is not good enough since it slows our build down from 40s to 14
minutes!! Can someone unfix this issue and suggest a more appropriate solution?

Original comment by galet.mi...@gmail.com on 3 Dec 2009 at 12:25

GoogleCodeExporter commented 9 years ago
I looked into it a year ago and I couldn't find any solution other than this. 
It's
quite a known problem if you google for it. If you have any ideas on how to 
solve
this please share them with us.

Original comment by johan.ha...@gmail.com on 3 Dec 2009 at 12:33

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Ignore my last comment. New issue is here:
http://code.google.com/p/powermock/issues/detail?id=122

Original comment by galet.mi...@gmail.com on 3 Dec 2009 at 12:47

GoogleCodeExporter commented 9 years ago
Take a look at issue 122 here as there is a simple fix for this:
http://code.google.com/p/powermock/issues/detail?id=122#c5

Original comment by annihil...@gmail.com on 12 Feb 2010 at 10:19

GoogleCodeExporter commented 9 years ago
This is excellent news. Thank you so much!

Original comment by johan.ha...@gmail.com on 12 Feb 2010 at 10:30