httpunit's test cases don't appear to address this, as any configuration pointing to "web.xml" appears to come from a dynamically-generated "web.xml" file. It would seem ideal to have and use a "WebContent" directory, just as would be used by most modern Java servlet containers. It could then be assumed that the "web.xml" could be loaded from "/WEB-INF/web.xml".
The best way to provide this may be to accept a File that points to the desired context root. Since ServletRunner already provide a constructor that takes a File, assuming it points to "web.xml", it could be checked for being a directory instead. If so, use it as the context root, then look for "web.xml" under the "WEB-INF" subdirectory.
The following inconsistencies should also be considered for improvement:
new ServletRunner(new File("TestWebContent/WEB-INF/web.xml"), null) or new ServletRunner(new File("TestWebContent/WEB-INF/web.xml"), "") somewhat works, though almost in reverse of this suggestion. It appears that the server's context root is set to the grandparent of "web.xml", or in this example, "TestWebContent". However, removing the 2nd argument, new ServletRunner(new File("TestWebContent/WEB-INF/web.xml")), uses the current working directory instead.
Additionally, providing any other value to the 2nd argument (other than null or an empty string) seems to require a leading "/", or the following error is thrown:
java.lang.IllegalArgumentException: Context path TestWebContent must start with '/'
This isn't documented in the API docs, and doesn't seem to provide any useful purpose, as any such use currently resolves to the root of the working drive. It would possibly make more sense if the leading "/" were to imply a meaningful location, e.g. the current working directory or some other defined parent.