Buggy HtmlUnitDriver: how to submit patches

7 views
Skip to first unread message

Marc Guillemot

unread,
Nov 16, 2009, 10:40:49 AM11/16/09
to webd...@googlegroups.com
Hi,

I regularly find new bugs in the current implementation of
HtmlUnitDriver. I'd like to see them fixed and I'm ready to submit
patches with appropriate tests. But here is my problem: WebDriver custom
test setup is not really clear for me and I don't see any documentation
for it.

Can someone tell me what is the simplest way to run a WebDriver unit
test (at best from the IDE)?

Cheers,
Marc.

Jason

unread,
Nov 16, 2009, 12:41:42 PM11/16/09
to webdriver
I'm not sure how much detail you need, so I'll just do a brain dump -
let me know if I leave anything out.

--------------------
Running the tests:

In IntelliJ you can just open HtmlUnitDriverTestSuite or
JavascriptEnabledHtmlUnitDriverTestSuite, right click the suite()
method and select run. I don't use Eclipse, but I imagine it's just
as straight forward.

--------------------
Restricting which tests get run:

That will run the entire suite of tests. If you only want to a
single class, call the onlyRun() method on the TestSuiteBuilder:

return new TestSuiteBuilder()
.addSourceDir("common")
.onlyRun("XPathElementFindingTest")
.create();

You can also restrict the suite to specific methods (which do not have
to be in the same class) using the method() command:

return new TestSuiteBuilder()
.addSourceDir("common")
.method("testShouldTrimText")
.method("testCanCreateAWellFormedCookie")
.create();

--------------------
Test Setup:

There are two suites for HtmlUnit, one that requires JavaScript to be
enabled, the other with it disabled. Tests that require JavaScript
should be annotated with @JavascriptEnabled.


If you need any more info, please let me know :)

-- Jason

Marc Guillemot

unread,
Nov 17, 2009, 2:29:46 AM11/17/09
to webd...@googlegroups.com
Hi,

I feared this response :-(

Is there a simple way to run a particular test using different drivers?
If I add a new test, I'm interested to run it at least with the FF and
HtmlUnit drivers.

Cheers,
Marc.

Jason a écrit :

Eran M.

unread,
Nov 17, 2009, 3:47:12 AM11/17/09
to webd...@googlegroups.com
Hi,

Aside from browser-specific test suites, all tests under common will run for all browsers (but you still have to explicitly invoke the test suite for each browser separately. There may be a rake target that runs all tests, I'm not sure).
Running the tests from the command line is simple. For firefox, for example:
rake test_firefox

The reason Jason suggested using the SingleTestSuite is that it's easy to run a specific test using it - which is what you would usually do when developing your tests. After the new tests have stabilized you may want to run the entire Firefox / HtmlUnit test suite.
At the moment there's no target to run the SingleTestSuite from the command line, as we mainly use it inside the IDE.

Hope this helps,
Eran

2009/11/17 Marc Guillemot <mguil...@yahoo.fr>

Marc Guillemot

unread,
Nov 19, 2009, 3:07:39 AM11/19/09
to webd...@googlegroups.com
Hi,

I've submitted a patch fixing issues in HtmlUnitDriver with
switchTo().frame(), getWindowHandle(), getPageSource(),
getValueOfCssProperty(), getLocation() and getSize():
http://code.google.com/p/webdriver/issues/detail?id=268

15 tests that were @Ignore for the HtmlUnitDriver are now green (not all
due to the patch).

I noticed that the Firefox test suite fails with one error when I run it
locally. Is this a known problem?

Some suggestions:
- what about running the @Ignore tests rather and expecting that the
test fails rather than skipping them? This would allow to detect tests
that have been fixed as side effects of some other changes. I guess that
half of the 15 tests that my patch "fixes" were in fact already working
with the HtmlUnitDriver. In HtmlUnit's build we run such tests as "not
yet implemented" and this often allows us to detect unplanned progress.
- what about using a custom JUnit @TestRunner? This would make IDE
integration far better. I've found current setup a bit cumbersome.

Cheers,
Marc.

Eran M. a écrit :
> Hi,
>
> Aside from browser-specific test suites, all tests under /common w/ill
> run for all browsers (but you still have to explicitly invoke the test
> suite for each browser separately. There may be a rake target that runs
> all tests, I'm not sure).
> Running the tests from the command line is simple. For firefox, for example:
> rake test_firefox
>
> The reason Jason suggested using the SingleTestSuite is that it's easy
> to run a specific test using it - which is what you would usually do
> when developing your tests. After the new tests have stabilized you may
> want to run the entire Firefox / HtmlUnit test suite.
> At the moment there's no target to run the SingleTestSuite from the
> command line, as we mainly use it inside the IDE.
>
> Hope this helps,
> Eran
>
> 2009/11/17 Marc Guillemot <mguil...@yahoo.fr <mailto:mguil...@yahoo.fr>>

Simon Stewart

unread,
Nov 19, 2009, 6:58:36 AM11/19/09
to webd...@googlegroups.com
Thanks for patches, Marc! Eran's taking a look at them now, but I
thought that I'd answer the question about why we don't run the Ignore
tests at all. The answer is that they have the potential to completely
wedge the build. You're right that it may be a good idea to run them
manually from time to time to see if we're being too conservative.

Regards,

Simon
Reply all
Reply to author
Forward
0 new messages