Run Twist Scenarios from Rake
Twist scenarios can be executed from within Rake. This makes Twist Continuous Integration friendly, and allows tests to be run as part of
a build within tools such as CruiseControl. For more information about Continuous Integration, please
visit http://martinfowler.com/articles/continuousIntegration.html
Export Twist Libraries
Using Rake Integration
Here are the steps required to do this:
- Export the dependencies of the project into a folder.
- As tests are implemented in Java in Twist, and Rake is written in Ruby, we suggest that scenarios be executed using system calls. Here is how a typical Rake task would look:
task :execute_scenarios do
dependencies = Dir.glob('{exported_location}/twist-libs/*.jar')
dependencies << '{Java_Output_direcotry}'
classpath = dependencies.join(File::PATH_SEPARATOR) unless dependencies.empty?
cmd_args = []
cmd_args << 'java'
cmd_args << '-classpath'
cmd_args << classpath
cmd_args << 'com.thoughtworks.twist.core.execution.ant.ScenarioExecutorAntMain'
cmd_args << File.expand_path('.', '{scenarios_folder_location}')
cmd_args << File.expand_path('.', '{reports_folder_location}')
cmd_args << File.expand_path('.', '{twist-conf_folder_location}')
cmd_args << '{comma_separated_tags}'
system (cmd_args.join ' ')
raise "Twist tests failed" if $?.exitstatus
end