code coverage problem NoClassDefFoundError

I run some benchmark tests with a .bat file via TeamCity,
those tests don't run any more since I switched CodeCoverage on, because of this exception:
: D:\BuildAgent\work\30cdf0ebbec9a63a\tempbuild>C:\Programme\Java\jdk1.5.0_13\... -Djava.library.path=bin -Xmx512m cdn.benchmark.Benchmark 0
: java.lang.NoClassDefFoundError: com/vladium/emma/rt/RT
: at cdn.benchmark.Benchmark.$VRi(Benchmark.java)
: at cdn.benchmark.Benchmark.]]>(Benchmark.java)
: Process exit code: 1

i could think of compiling again without coverage before running this test, is this what is required,
or is there another quick fix for this?

10 comments

EMMA instruments your class files and when you start them you need emma.jar in classpath. I think benchmarking tests should not be run with coverage because instrumented classes will produce some overhead and may affect performance of your tests.

--
Pavel Sher

0

If you still want to run your benchmark tests with coverage,
you may add emma.jar from ../../plugins/coveragePlugin/lib to the classpath of your tests.

Hope this helps,
KIR

0

thanks for the replies.
I was aware that the emma.jar is required in classpath.
I want to run the benchmarks without emma.jar.

I am not sure what the suggested approach is to do this.

the benchmark is started via a command line. it uses the compiled classes from a "normal" build run before.
I guess I should now add a build configuration that compiles without code coverage, and make the benchmark build depend on that one?

0

You're right, your benchmark build should not depend on classes compiled with coverage information.
So you need "clean" build, without enabled coverage.

Regards,
KIR

0

I have another problem: if I add dependence on non-instrumented build in the benchmark build config,
it says that this will trigger a benchmark each time the non-instrumented build is running.

this is not 100% what i want.
i want some benchmarks to run nightly, others weekly.
Now I see the only possibility to do this by adding dependency on non-instrumented build, and let the uninstr. build run nightly.
But what about the weekly benchmark? I would have to add a kind of "dummy-non-instrumented-build2" that runs only weekly.

Is there another way?

0

Hello Michael,

In fact, TeamCity has two types of dependencies by the moment: trigger dependencies, and artifact dependencies.

Trigger dependencies are used to trigger dependent configuration when master configuration is successful. It doesn't guarantee that builds will run on the same build agent.

Artifact dependencies allow to pass files and directories between build configurations.

I suppose that you need artifact dependencies for your weekly and nightly builds, not trigger dependencies.

Moreover, if you have only one build agent, which runs your build configurations, there is no need to configure dependencies at all. Especially if they use same checkout directory and same checkout settings.

If you have several build agents, you may prepare jar files with classes in master configuration, specify these jar files as build artifacts, and than require these jar files in benchmark build configuration in "Artifact dependencies" section.

Hope this helps,
KIR

0

Kirill, thanks again for the reply.

What I am lacking is kind of a ready-made recipe. There still is a problem - let me explain:
I DO have a dependency, because I need to ensure that my benchmark runs on non-instrumented classes.
So I can not just use the normal build configuration (where the java code is compiled), because there it is compiled with emma (code coverage),
and I dont want to run the benchmarks with emma. Btw. I would also have a bad feeling about adding the emma.jar to the project for running benchmarks,
while the unit tests themselves run with emma without having it added to the project - you understand? ;)
In other words: with the unit tests it is very convenient, just check the box in the team city build config "code coverage", and it runs, without adding emma.jar to the project.
but my benchmark is left out in the cold ;)

What I need now is a way to easily ensure that, when my benchmark1 runs nightly, or the benchmark3 runs weekly, I need the non-instrumented newest classes BEFORE running the benchmark.
Do you understand the problem?

Or, in other words again: I have one build configuration called "main" which compiles java, runs testng tests (with code coverage) and also produces a .jar
Fine, this "main"-config runs on every checkin.
Now I have a builc onfiguration called "benchmark1" which runs nightly. This one now fails due to missing emma.jar.
I dont want to add emma.jar to classpath - so how do I fix the "benchmark1" config?

I added an additional build config called "uninstrumented", scheduled it nightly, and added dependency from benchmark1 to uninstrumented.
This way, the uninstrumented runs nightly, giving me non-instrumented class files as intented, then the benchmark1 is triggered -ok.

But... now if I add the dependency to benchmark3, which is intended weekly, I would end up running it nightly - yes? ;)
So, to fix this, I would have to add a hacky "uninstrumented-weekly" just to fix this.

There has to be a smarter way, what do you think?

0

Michael,

I think you should use the following configuration:

1. main build with coverage run on every checkin
2. uninstrumented build without coverage run at 01:00 daily
3. daily benchmark build which depends on 2 and uses artifacts/jars from 2 (via artifact dependency)
4. weekly benchmark build which runs weekly at 02:00 and uses artifacts/jars from 2 (via artifact dependency)

Does it make sense? I see no reason why do you need uninstrumented-weekly configuration

Regards,
KIR

0

yes, you are right, thank you - only one minor addition: I should make sure that the weekly benchmark runs after the daily one, so that the newest changes will be contained in the weekly benchmark too.

0

Please sign in to leave a comment.