• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Integrating Emma coverage with StrutsTestCase / Cactus

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
It's hard to fight evil. The little things, like a nice sandwich, really helps. Right tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic