When you issue ‘mvn gwt:test’, Maven creates a target/www-test -directory. This dir contains the actual tests being ran under another directory based on you package, e.g. target/www-test/com.mydomain.test.SomeApp.JUnit
I need to include a javascript file to this directory, or my tests will fail. How do I do this ? The documentation doesn’t seem to provide an option to include files here.
The subfolder name is actually based upon the module name your
GWTTestCasereturns fromgetModuleName(), with aJUnitsuffix (GWT generates on-the-fly a module that inherits your module and thecom.google.gwt.junit.JUnitmodule, among other things).So, if you need some specific things for your test, you can very well create a test-specific module that inherits your “standard” module, and return that new module from
getModuleName(GWT unit tests do that for testing someset-propertyorset-configuration-propertyvalues, or declareservlets for testing GWT-RPC, RequestFactory orFormPanel, for instance).Now, if you only need a JS file, you can put it in your public path (i.e. by default, a
publicfolder next to yourgwt.xmlmodule descriptor file). And you can use<script>in yourgwt.xmlto automatically pull that script inside the test page (because tests use a standardjunit.htmlorjunit-standard.htmlweb page). If you really need to, you can override that HTML page by putting one with the same name in your public path, it should then override the one from thecom.google.gwt.junit.JUnitmodule (you might have to explicitly inherit that module though, so its public path comes before yours)See also:
https://developers.google.com/web-toolkit/doc/latest/DevGuideOrganizingProjects#DevGuideModules
http://code.google.com/p/google-web-toolkit/wiki/ResourceOracle