Code Coverage : How to configure cobertura and selenium with Gwt Client project for code coverage

1,071 views
Skip to first unread message

Sun Raise

unread,
Mar 26, 2012, 8:47:49 AM3/26/12
to Google Web Toolkit
Hi,

I am using GWT client side project.

I am interesting selenium automated test case in my project.

For code coverage i want to use cobertura.


How to configure these 2 tools in gwt client ?

Its it possible or not ?

Thanks

Thomas Broyer

unread,
Mar 26, 2012, 10:07:28 AM3/26/12
to google-we...@googlegroups.com
AFAIK, only EMMA (a patched version of EMMA) can be used for measuring code coverage in client code.

As for Selenium, I'm sorry, I never took the time to use it. IIUC, you'd have to launch the DevMode with EMMA-enhanced classes, and then point your browser (controlled by Selenium) to it to run the tests.

If you use Maven, you'd launch the DevMode in the pre-integration-test phase and run the selenium tests in the integration-test phase; then stop the DevMode in the post-integration-test phase and process the EMMA reports and test reports in the verify phase. The gwt-maven-plugin could have helped you launch the DevMode, but AFAIK it's blocking, so it actually won't help.

Joseph Lust

unread,
Mar 27, 2012, 10:58:17 PM3/27/12
to google-we...@googlegroups.com
Thomas,

Have you ever used the patched Emma plugin? I've got the Emma 2.1.0.201 installed while the 'patched' version is 2.0.5312. I tried swapping things out like the docs suggested to no avail. Curious if anyone else has made that work in Indigo (Ubuntu 11.10).

I've long used Emma with pure Java, but it does not work on GWTTestCase. I can run the case or suite with RunAs>GWT JUnit Test, but using Emma or Coverage As > JUnit Test always throws:

com.google.gwt.junit.JUnitFatalLaunchException: The test class 'com.myPkg.myClass' was not found in module 'com.myPkg.MyModule'; no compilation unit for that type was seen
at com.google.gwt.junit.JUnitShell.checkTestClassInCurrentModule(JUnitShell.java:743)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1346)
at com.google.gwt.junit.JUnitShell.runTestImpl(JUnitShell.java:1309)
at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:653)
at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:441)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:296)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at junit.framework.TestSuite.runTest(TestSuite.java:243)
at junit.framework.TestSuite.run(TestSuite.java:238)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Perhaps the patch needs to be updated? I can build it myself, but did not see a reference to the patch on the Google page.


Sincerely,
Joseph

Thomas Broyer

unread,
Mar 28, 2012, 4:23:50 AM3/28/12
to google-we...@googlegroups.com
I never used it. I know GWT can be built with EMMA enabled for the tests (ant -Demma.enabled=true), I haven't run it for a while but I believe it still works.
The patch is here, with the instructions for re-building EMMA in the README.txt: http://code.google.com/p/google-web-toolkit/source/browse/tools/redist/emma/

dodo dard

unread,
Mar 28, 2012, 10:37:41 AM3/28/12
to google-we...@googlegroups.com
I've work with GWT and Selenium separately, But to make Selenium work, basically you have set and unique id to the component that you want to test.  But then for Cobertura, I dont know

Joseph Lust

unread,
Mar 28, 2012, 11:06:33 AM3/28/12
to google-we...@googlegroups.com
Thomas,

Thanks for the tip. I'll rebuild GWT and Emma when I get home with these flags tonight.

Sincerely,
Joseph

Joseph Lust

unread,
Mar 29, 2012, 3:34:00 PM3/29/12
to google-we...@googlegroups.com
Dodo,

We get around that by setting unique id's on elements using a 'debugId' for components that need to be individually tested. This helps prevent making brittle tests that depend on a very long XPath that will break if any class is renames or div moved.

You can set them in the UiBinder as just debugId="value" up to GWT 2.3, there after you need to programmaticly set them in the Java side.

Sincerely,
Joe
Reply all
Reply to author
Forward
0 new messages