Search code examples
javascriptunit-testingantbuild-automationjsunit

How to specify a relative path for the jsUnit-ant-script?


JsUnit provides an ant-script with the target 'standalone_test'. This target uses the property url to identify the HTML-site, that executes the tests. These site is checked in, so that everyone should be able after a checkout to execute this tests. This works, but the url-proprty must be set to an absolute path, like file:///home/user/projects/my-project/path/in/project/jsunit/testRunner.html. That avoids an automatic start, everyone have too specify a command with the path constructed on his box. Is it possible to pass a relative path/url instead, so that the execution of these tests can be automated? This would be helpful to setup these test in our continuous-integration-system.


Solution

  • You could construct the url property value using the built-in Ant basedir property.

    For example, if your build script is located in and run from your /home/user/projects/my-projects directory you could set your url property as:

    <property
        id="url"
        name="url"
        value="file://${basedir}/path/in/project/jsunit/testRunner.html"/>