Tests are run with:
This script will run both the unit tests and the Selenium tests.
Dryad uses the standard set of DSpace unit tests, based on JUnit. These tests are found in the src/test directory of each module. By default, testing is disabled for normal compilation. Running the tests with every compile is counterproductive, because it adds too much time to the compile process.
Selenium tests UI-specific functionality. Dryad maintains a set of Selenium tests in the selenium directory of the repository. These tests are run separately from the normal compilation process, because they require a running instance of Dryad.
These tests can be checked out and run (with "mvn package"). Since they work through a web browser, they do not need any Dryad code present on the testing machine.
- Firefox plugin for automating tasks within firefox.
- It internally stores scripts as HTML, but it can export scripts in Java/Ruby/Python code suitable for use with WebDriver/RC.
- can record script through web page actions and then replay to test
- can export script in variety of formats (JUnit, Ruby, C#)
- Exported scripts are relatively brittle and must be modified for general use, but are a great starting point.
- Tool that can launch a browser, execute a test script, and report results of the test.
- Can be used with JUnit or other testing frameworks.
- Doesn't require running a separate server.
- The "future" of Selenium.
Configuring Firefox: This is no problem on a desktop/laptop with Firefox installed. It will work automatically. On a server, you must:
- ensure firefox is installed
- in the root account, run "Xvfb :99"
- the the account that is running selenium, "export DISPLAY=:99"
- Create initial tests with IDE, then export to your target language/format and edit.
- Use the HtmlUnitDriver instead of the default FirefoxDriver if possible -- it is faster, and runs without modification on more systems.
- When creating a test in the IDE, use "assert" statements for all tests, because "verify" statements don't export properly to the code.
- When modifying the testing code, use "verify" statements for any non-fatal errors. Use "assert" statements for errors that will cause the rest of the test to be meaningless.
Checklist for exporting a test from the IDE to Webdriver:
- Ensure the test has a name ending in Test (for JUnit compatability)
- Perform the export.
- Make the test extend JUnit's TestCase class.
- Modify the test to use HtmlUnitDriver.
- Modify all assertions/verifications (these will appear as comments with an error message) to use the existing webdriver api
- Ensure that a base URL is set.
- Add it to any appropriate test suites.
Relation to DSpace
Dryad uses the standard DSpace unit tests and integration tests. See DSpace Testing.