• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Integrating Emma coverage with StrutsTestCase / Cactus

 
Fahim Farook
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34860
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Fahim Farook
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34860
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic