From: Brian D. <bri...@ya...> - 2005-03-10 16:50:54
|
Sure here is what I've got for the details: src/com application-context.xml test/com classes build/classes instrumented-classes The src/ directory has the production code and gets compiled to the build/classes directory. The unit test source is compiled into the test/classes directory. After compiling and before running the unit tests I instrument the production code to the build/instrumented-classes directory. I do a command line diff on the build/classes and build/instrumented-classes directories after compiling and there is no difference at all. When I run the unit tests I'm putting the instrumented directory first in the classpath and the build-classes second and the src third (I put the src into the classpath to pick up the application-context.xml) In the setup of the unit tests it will call ClassPathXmlApplicationContext to load in the applicationContext.xml. When I run the unit tests I get 0% coverage. Per Mark's suggestion I copied the instrumented files over to the build/classes directory (thus overwriting the non-instrumented files) and then the first test case that runs and gets a bean from the applicationController in Spring fails with the error: [junit] org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'webController' defined in class path resource [applicationContext.xml]: Class that bean class [com.aptas.etosha.web.webcontroller.DefaultWebControllerImpl] depends on not found; nested exception is java.lang.NoClassDefFoundError: com/aptas/etosha/web/webcontroller/WebController This class exists and is present in the both the build/classes and build/instrumented-classes directories. It appears that when instrumenting the classes something happens such that Spring cannot find those instrumented files at all. Thanks! --- Jeremy Ryan Thomerson <je...@th...> wrote: > Brian, can you give a few more details about your setup? I use a > Spring/Ant > mix for all of our unit tests so that each has access to the > application > context. I might be able to help with a few mroe details. > > Jeremy Thomerson > > ----- Original Message ----- > From: "Brian Doyle" <bri...@ya...> > To: "Mark Doliner" <Mar...@sa...>; > <Cob...@li...> > Sent: Wednesday, March 09, 2005 5:14 PM > Subject: [SPAM-LOW] RE: [Cobertura-devel] 0% code coverage > > > > I just copied the instrumented classes to the pre-instrumented > > directory and it still fails with the same message :( If I copy > the > > non-instrumented classes back, it runs but I'm back to 0% > coverage. > > I'll try out Clover or EMMA and see if it's just something basic > I'm > > doing wrong here. Thanks for your help! > > > > --- Mark Doliner <Mar...@sa...> wrote: > > > > > The package names and class names should remain the same. It > > > SOUNDS like Spring isn't looking for classes in the > "instrumented" > > > directory. You could try moving/copying these files to where > the > > > pre-instrumented classes were. (That's probably not an ideal > > > long-term solution, but it might help narrow down the problem.) > > > -Mark > > > > > > > -----Original Message----- > > > > From: cob...@li... > > > > [mailto:cob...@li...] On > > > > Behalf Of Brian Doyle > > > > Sent: Wednesday, March 09, 2005 4:05 PM > > > > To: Cob...@li... > > > > Subject: RE: [Cobertura-devel] 0% code coverage > > > > > > > > Thanks for the suggestions! I'm made some progress but > still > > > not > > > > quite working for me. When I removed the original classes > and > > > run > > > > the unit tests I get a NoClassDefFoundError for any of the > > > production > > > > classes. I am using Spring which loads the files up by > > > specifying > > > > the full package and name of the applicationContext.xml. > Spring > > > is > > > > actually throwing the NoClassDefFoundError itself and can't > seem > > > to > > > > find the file. The file actually exists in the instrumented > > > > directory. I was wondering when the class does get > instrumented > > > does > > > > it change the package name or name of the class when it's > running > > > in > > > > the JVM. If that is the case that would explain why Spring > can't > > > > find the class to load. Thanks! > > > > > > > > --- Mark Doliner <Mar...@sa...> wrote: > > > > > It sounds like you have a pretty good understanding of what > > > should > > > > > be happening. I'm not actually sure if the file size of > > > > > cobertura.ser should grow... I can't think of why it would, > but > > > > > from experience I think it does. The time stamp on the > file > > > would > > > > > definitely be changed. You could try removing the original > > > classes > > > > > before running the tests, to be absolutely sure you're > using > > > the > > > > > instrumented classes. > > > > > > > > > > The cobertura.ser file is generally only written when the > JVM > > > > > exists. I suppose it's possible that you run your tests, > and > > > then > > > > > the ser file is written, then maybe you run another test in > a > > > new > > > > > JVM and it overwrites the ser file. (That's something I'd > like > > > to > > > > > see fixed sometime, maybe for the next version.) > > > > > -Mark > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > From: cob...@li... > > > > > > [mailto:cob...@li...] On > > > > > > Behalf Of Brian Doyle > > > > > > Sent: Wednesday, March 09, 2005 12:57 PM > > > > > > To: Cob...@li... > > > > > > Subject: [Cobertura-devel] 0% code coverage > > > > > > > > > > > > I'm attempting to use Cobertura for the first time and > the > > > report > > > > > > shows up as 0% coverage even though I have unit tests. > I > > > assume > > > > > > that the cobertura.ser file is suppose to grow as the > unit > > > test > > > > > are > > > > > > running? That file is created and it never changes in > size. > > > The > > > > > ant > > > > > > build is always in the same directory, running, compiling > and > > > > > > creating reports and there's only one of those > cobertura.ser > > > > > files. > > > > > > Also the classpath for the unit tests has the > instrumented > > > > > classes as > > > > > > the first thing in the path. The instrumented classes is > > > > > populated > > > > > > with classes. Not sure what else to check here. Any > ideas? > > > > > Thanks. > > > > > > > > > > > > > > > > > > Brian Doyle > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > > SF email is sponsored by - The IT Product Guide > > > > > Read honest & candid reviews on hundreds of IT Products > from > > > real > > > > > users. > > > > > Discover which products truly live up to the hype. Start > > > reading > > > > > now. > > > > > http://ads.osdn.com/?ad_ide95&alloc_id396&op=click > > > > > _______________________________________________ > > > > > Cobertura-devel mailing list > > > > > Cob...@li... > > > > > > https://lists.sourceforge.net/lists/listinfo/cobertura-devel > > > > > > > > > > > > > Brian Doyle > > > > > > > > I don't know about ignorance, and I don't care about apathy, > > > > but I simply will not put up with intolerance! - Unknown > > > > > > > > > > > > ------------------------------------------------------- > > > > SF email is sponsored by - The IT Product Guide > > > > Read honest & candid reviews on hundreds of IT Products from > > > > real users. > > > > Discover which products truly live up to the hype. Start > reading > > > now. > > > > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > > > > _______________________________________________ > > > > Cobertura-devel mailing list > > > > Cob...@li... > > > > https://lists.sourceforge.net/lists/listinfo/cobertura-devel > > > > > > > > > > > > > ------------------------------------------------------- > > > SF email is sponsored by - The IT Product Guide > > > Read honest & candid reviews on hundreds of IT Products from > real > > > users. > > > Discover which products truly live up to the hype. Start > reading > > > now. > > > http://ads.osdn.com/?ad_ide95&alloc_id396&op=click > > > _______________________________________________ > > > Cobertura-devel mailing list > > > Cob...@li... > > > https://lists.sourceforge.net/lists/listinfo/cobertura-devel > > > > > > > > > Brian Doyle > > > > I don't know about ignorance, and I don't care about apathy, but > I simply > will not put up with intolerance! - Unknown > > > > > > ------------------------------------------------------- > > SF email is sponsored by - The IT Product Guide > > Read honest & candid reviews on hundreds of IT Products from real > users. > > Discover which products truly live up to the hype. Start reading > now. > > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > > _______________________________________________ > > Cobertura-devel mailing list > > Cob...@li... > > https://lists.sourceforge.net/lists/listinfo/cobertura-devel > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real > users. > Discover which products truly live up to the hype. Start reading > now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Cobertura-devel mailing list > Cob...@li... > https://lists.sourceforge.net/lists/listinfo/cobertura-devel > --- Jeremy Ryan Thomerson <je...@th...> wrote: > Brian, can you give a few more details about your setup? I use a > Spring/Ant > mix for all of our unit tests so that each has access to the > application > context. I might be able to help with a few mroe details. > > Jeremy Thomerson > > ----- Original Message ----- > From: "Brian Doyle" <bri...@ya...> > To: "Mark Doliner" <Mar...@sa...>; > <Cob...@li...> > Sent: Wednesday, March 09, 2005 5:14 PM > Subject: [SPAM-LOW] RE: [Cobertura-devel] 0% code coverage > > > > I just copied the instrumented classes to the pre-instrumented > > directory and it still fails with the same message :( If I copy > the > > non-instrumented classes back, it runs but I'm back to 0% > coverage. > > I'll try out Clover or EMMA and see if it's just something basic > I'm > > doing wrong here. Thanks for your help! > > > > --- Mark Doliner <Mar...@sa...> wrote: > > > > > The package names and class names should remain the same. It > > > SOUNDS like Spring isn't looking for classes in the > "instrumented" > > > directory. You could try moving/copying these files to where > the > > > pre-instrumented classes were. (That's probably not an ideal > > > long-term solution, but it might help narrow down the problem.) > > > -Mark > > > > > > > -----Original Message----- > > > > From: cob...@li... > > > > [mailto:cob...@li...] On > > > > Behalf Of Brian Doyle > > > > Sent: Wednesday, March 09, 2005 4:05 PM > > > > To: Cob...@li... > > > > Subject: RE: [Cobertura-devel] 0% code coverage > > > > > > > > Thanks for the suggestions! I'm made some progress but > still > > > not > > > > quite working for me. When I removed the original classes > and > > > run > > > > the unit tests I get a NoClassDefFoundError for any of the > > > production > > > > classes. I am using Spring which loads the files up by > > > specifying > > > > the full package and name of the applicationContext.xml. > Spring > > > is > > > > actually throwing the NoClassDefFoundError itself and can't > seem > > > to > > > > find the file. The file actually exists in the instrumented > > > > directory. I was wondering when the class does get > instrumented > > > does > > > > it change the package name or name of the class when it's > running > > > in > > > > the JVM. If that is the case that would explain why Spring > can't > > > > find the class to load. Thanks! > > > > > > > > --- Mark Doliner <Mar...@sa...> wrote: > > > > > It sounds like you have a pretty good understanding of what > > > should > > > > > be happening. I'm not actually sure if the file size of > > > > > cobertura.ser should grow... I can't think of why it would, > but > > > > > from experience I think it does. The time stamp on the > file > > > would > > > > > definitely be changed. You could try removing the original > > > classes > > > > > before running the tests, to be absolutely sure you're > using > > > the > > > > > instrumented classes. > > > > > > > > > > The cobertura.ser file is generally only written when the > JVM > > > > > exists. I suppose it's possible that you run your tests, > and > > > then > > > > > the ser file is written, then maybe you run another test in > a > > > new > > > > > JVM and it overwrites the ser file. (That's something I'd > like > > > to > > > > > see fixed sometime, maybe for the next version.) > > > > > -Mark > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > From: cob...@li... > > > > > > [mailto:cob...@li...] On > > > > > > Behalf Of Brian Doyle > > > > > > Sent: Wednesday, March 09, 2005 12:57 PM > > > > > > To: Cob...@li... > > > > > > Subject: [Cobertura-devel] 0% code coverage > > > > > > > > > > > > I'm attempting to use Cobertura for the first time and > the > > > report > > > > > > shows up as 0% coverage even though I have unit tests. > I > > > assume > > > > > > that the cobertura.ser file is suppose to grow as the > unit > > > test > > > > > are > > > > > > running? That file is created and it never changes in > size. > > > The > > > > > ant > > > > > > build is always in the same directory, running, compiling > and > > > > > > creating reports and there's only one of those > cobertura.ser > > > > > files. > > > > > > Also the classpath for the unit tests has the > instrumented > > > > > classes as > > > > > > the first thing in the path. The instrumented classes is > > > > > populated > > > > > > with classes. Not sure what else to check here. Any > ideas? > > > > > Thanks. > > > > > > > > > > > > > > > > > > Brian Doyle > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > > SF email is sponsored by - The IT Product Guide > > > > > Read honest & candid reviews on hundreds of IT Products > from > > > real > > > > > users. > > > > > Discover which products truly live up to the hype. Start > > > reading > > > > > now. > > > > > http://ads.osdn.com/?ad_ide95&alloc_id396&op=click > > > > > _______________________________________________ > > > > > Cobertura-devel mailing list > > > > > Cob...@li... > > > > > > https://lists.sourceforge.net/lists/listinfo/cobertura-devel > > > > > > > > > > > > > Brian Doyle > > > > > > > > I don't know about ignorance, and I don't care about apathy, > > > > but I simply will not put up with intolerance! - Unknown > > > > > > > > > > > > ------------------------------------------------------- > > > > SF email is sponsored by - The IT Product Guide > > > > Read honest & candid reviews on hundreds of IT Products from > > > > real users. > > > > Discover which products truly live up to the hype. Start > reading > > > now. > > > > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > > > > _______________________________________________ > > > > Cobertura-devel mailing list > > > > Cob...@li... > > > > https://lists.sourceforge.net/lists/listinfo/cobertura-devel > > > > > > > > > > > > > ------------------------------------------------------- > > > SF email is sponsored by - The IT Product Guide > > > Read honest & candid reviews on hundreds of IT Products from > real > > > users. > > > Discover which products truly live up to the hype. Start > reading > > > now. > > > http://ads.osdn.com/?ad_ide95&alloc_id396&op=click > > > _______________________________________________ > > > Cobertura-devel mailing list > > > Cob...@li... > > > https://lists.sourceforge.net/lists/listinfo/cobertura-devel > > > > > > > > > Brian Doyle > > > > I don't know about ignorance, and I don't care about apathy, but > I simply > will not put up with intolerance! - Unknown > > > > > > ------------------------------------------------------- > > SF email is sponsored by - The IT Product Guide > > Read honest & candid reviews on hundreds of IT Products from real > users. > > Discover which products truly live up to the hype. Start reading > now. > > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > > _______________________________________________ > > Cobertura-devel mailing list > > Cob...@li... > > https://lists.sourceforge.net/lists/listinfo/cobertura-devel > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real > users. > Discover which products truly live up to the hype. Start reading > now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Cobertura-devel mailing list > Cob...@li... > https://lists.sourceforge.net/lists/listinfo/cobertura-devel > Brian Doyle I don't know about ignorance, and I don't care about apathy, but I simply will not put up with intolerance! - Unknown |