Created
December 17, 2010 14:26
-
-
Save searls/745009 to your computer and use it in GitHub Desktop.
HtmlUnit's documentation doesn't make it abundantly clear how to run assertions against an HTML string snippet (i.e. the easiest way to run tests when you don't care about URLs, network connections, etc.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private HtmlPage getPage(String html) { | |
MockWebConnection webConnection = new MockWebConnection(); | |
webConnection.setDefaultResponse(html); | |
WebClient webClient = new WebClient(); | |
webClient.setWebConnection(webConnection); | |
try { | |
return webClient.getPage("http://blah"); | |
} catch (Exception e) { | |
throw new RuntimeException(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment