wood burning stoves 2.0*
The moose likes Testing and the fly likes Integrating Emma coverage with StrutsTestCase / Cactus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Integrating Emma coverage with StrutsTestCase / Cactus" Watch "Integrating Emma coverage with StrutsTestCase / Cactus" New topic
Author

Integrating Emma coverage with StrutsTestCase / Cactus

Fahim Farook
Greenhorn

Joined: Mar 20, 2011
Posts: 12
I have a struts 1.2 Java project and I'm using StrutsTestCase for unit testing action classes. Also I have configured Emma for coverage. However I'm getting almost 0% coverage for action classes always.

Is that because, when using StrutsTestCase we call action classes using



and we do not call the action method explicitly? (i.e. actionObj.actionMethod();)

If so how can I configure Emma to get the actual coverage with StrutsTestCase. Or is there any other workaround? Please help.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

No, Emma should run whether you call the code directly or not. Are you sure that Emma is set to instrument those classes? You can test this be writing a test that simply calls one of the action class methods and see what happens. Or add a new method to the action class that doesn't have any dependencies.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Fahim Farook
Greenhorn

Joined: Mar 20, 2011
Posts: 12
Thanks Jeanne for the reply. Could you plase explain a bit further...

i.e. What is the purpose of adding new methods to action class?

Fahim Farook
Greenhorn

Joined: Mar 20, 2011
Posts: 12
Hi Jeanne, I could find all the source (not test classes) classes in the instrumented-classes folder. However I'm getting o% method/ line coverage for action methods. However for non-action methods, it gives 100% method coverage. Could you plase advice here...
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

Fahim Farook wrote:Thanks Jeanne for the reply. Could you plase explain a bit further...

i.e. What is the purpose of adding new methods to action class?


It's a troubleshooting aid. If you a new method to the action class (say a method that always returns "test") and a test for it, you see if the new method gets covered. If it does, that tells you that the instrumentation is fine and the problem is that Cactus is running in a different JVM that isn't instrumented. This seems likely as Cactus runs your code on the server. If your new method isn't tested, you know there was a problem in instrumenting.

When I troubleshoot, I like to put the problem in a smaller box until it has nowhere to hide!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Integrating Emma coverage with StrutsTestCase / Cactus
 
Similar Threads
Getting Logging jar is sealed Error
EMMA and J2EE
Emma and RMI
How to run Jboss under Emma to find code coverage
Emma Coverage