Back    
Priority:
Type:
State:
Assignee:
Subsystem:
Affected versions:
Fixed in:

TW-1305

Build fails when using Code Coverage with TestNG

0
TestNG fails when code coverage is switched on. Build succeeds with all tests passing when code coverage is switched off.

This is the output:

test.all (4s)
[mkdir] Created dir: /export/home/develop/buildAgent/work/My_Project/build/test
[test.all] path (<1s)
[test.all] taskdef (<1s)
[test.all] testng (4s)
[testng] Unit Tests (1s)
[testng] [Utils] FAILED TO CREATE CLASS class com.chaucerdigital.myproject.MyTest

=======================================

Unit Tests
Total tests run: 0, Failures: 0, Skips: 0

=======================================


[testng] [ERROR]: java.lang.reflect.InvocationTargetException
[testng] The tests failed.
EMMA: Create Report (<1s)
[EMMA: Create Report] EMMA: processing control command sequence ...
[EMMA: Create Report] EMMA: executing [coverage.dump (,,true)] ...
[EMMA: Create Report] Unable to find /export/home/develop/buildAgent/work/My_Project/coverage.ec, cannot create EMMA report

Environment: Team City web server is on Windows Server 2003.
Build agent is on Solaris 10 (Sparc64).
Both have JDK 1.5
Using TestNG 5.1

Issue wasresolved
Comments (5)
History (1)
Kirill Maximov Kirill Maximov 09 Dec 2006 13:45 (2 years ago)
Could you please try verbose="9" in your testng.xml configuration and attach full build log text with this setting enabled?
Daniel Dyer Daniel Dyer 12 Dec 2006 18:51 (2 years ago)
As requested, set verbose to 9, only additional output was a list of classes skipped (all correct) and the full stack-trace for the error. Looks like it can't find the EMMA classes.

org.testng.TestNGException:

Cannot instantiate class com.chaucerdigital.myproject.MyTest

at org.testng.internal.Utils.createInstance(Utils.java:481)
at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:59)
at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:81)
at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:69)
at org.testng.TestRunner.initMethods(TestRunner.java:246)
at org.testng.TestRunner.init(TestRunner.java:193)
at org.testng.TestRunner.init(TestRunner.java:163)
at org.testng.TestRunner.<init>(TestRunner.java:122)
at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:427)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:203)
at org.testng.SuiteRunner.run(SuiteRunner.java:168)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:969)
at org.testng.TestNG.runSuitesLocally(TestNG.java:933)
at org.testng.TestNG.run(TestNG.java:701)
at org.testng.TestNG.privateMain(TestNG.java:1001)
at org.testng.TestNG.main(TestNG.java:979)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at org.testng.internal.Utils.createInstance(Utils.java:472)

... 15 more
Caused by: java.lang.NoClassDefFoundError: com/vladium/emma/rt/RT
at com.chaucerdigital.myproject.MyNonTestClass.$VRi(MyNonTestClass.java)
at com.chaucerdigital.myproject.MyNonTestClass.<clinit>(MyNonTestClass.java)
at com.chaucerdigital.poker.myproject.MyTest.<init>(MyTest.java:14)

... 20 more
[testng] The tests failed.
EMMA: Create Report (5s)
[EMMA: Create Report] Unable to find /export/home/develop/buildAgent/work/My_Project/coverage.ec, cannot create EMMA report
Daniel Dyer Daniel Dyer 12 Dec 2006 18:53 (2 years ago)
I should add that I am now using build 3274 and TestNG 5.4 and I am still getting the problem.
Alex Popescu Alex Popescu 12 Dec 2006 20:47 (2 years ago)
This is the comment I have posted on TestNG ML:

[quote]
Thinking about this more I might see a possible problem:

  • code coverage tools may need to use a special class loader to weave

the tests in order to gather the required data
  • TestNG loads the test classes through reflection mechanism


If these 2 steps are using different classloader hierarchies then I
think there will be problems.

Can you help me with more details about what code coverage solution is
used in IDEA? Maybe I can further investigate the problem, but I would
definitely need to dig in the code to see what exactly are they doing.
If the problem comes from my above supposition then fixing it would be
quite tricky, but I may have a couple of ideas.
[/quote]

./alex
--
.w( the_mindstorm )p.
TestNG co-founder
EclipseTestNG Creator
Kirill Maximov Kirill Maximov 13 Dec 2006 13:35 (2 years ago)
The problem is that to run instrumented classes for TestNG we should have added emma.jar to class path (like we do for JUnit tests).
I'll try to investigate the problem in the nearest time.