The test framework is RSpec.
Tests are run by running rspec
.
You may use RSpec command line options when running the tests. A list of options is available
by typing rspec --help
.
There are many tutorials and style guides available for writin gin RSpec
The extra goodness is contained in rubytests/spec/configuration.rb
. Each test must require this file,
usually with a command like this:
require_relative '../../configuration'
What additions does configuration.rb
provide?
RSpec is intended for small, independent test steps (called "examples"). In contrast, each vivo acceptance test is a series of related test steps, each one relying on the successful execution of the previous steps.
configuration.rb
forces the --order defined
option, so the test steps are run in the
expected order within each test.
configuration.rb
contains logic saying that if a test step fails, the remaining steps in that test
are skipped.
configuration.rb
also forces the --format documentation
option, so each test step is listed
in the standard output.
An instance of Selenium::WebDriver::Driver
that represents the Chrome browser in the test.
Test steps call methods on the driver, like this:
$browser.find_element(:link_text, "Index").click
Contains the settings you provide in environment variables and/or a settings file.
$settings
is not referenced in the tests themselves.
However, it can be useful if you write a before_starting_server()
method to do
additional VIVO configuration.
Here is an example of using the VIVOTEST_OUTPUT_DIRECTORY
setting to add an
RDF file to VIVO.
def before_starting_server
source = File.expand_path("TestSearchExclusion.n3", File.dirname(__FILE__))
dest = File.expand_path("home/rdf/display/everytime", $settings.output_path)
FileUtils.cp(source, dest)
end
This object is essentially a wrapper around the shell scripts that set up the execution environment, and start or stop the server.
It is not referenced in the tests themselves.
configuration.rb
includes three helper modules, which provide helpful methods
to the tests. Here is a list of the methods.
- Clear the output directory.
- In the output directory, create a
logs
directory and afailures
directory.
- Clear the
logs
directory. - Assemble a clean VIVO context.
- Assemble a clean home directory
- This also cleans the triple-stores, the search index, and the uploaded files.
- If the test contains a
before_starting_server()
method, call it. - Start VIVO.
- If the step failed, capture diagnostic information:
- The source HTML for the current page.
- A screenshot of the current page.
- The logs (TO DO)
- If the step failed, skip to the end of the test and start the next one.
- Stop VIVO.
Look here for more information about creating the VIVO runtime environment.