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
# set these to the relative location of your project
project_location = "."
# the classes for the project are generated here
project_output_location = File.expand_path(project_location, "bin")
# the tags to execute
tags = "!in-progress"
# number of parallel threads to execute
threads = "1"
# you need not change anything below this
# the dependencies required for executing the tests
dependencies = Dir.glob("${exported_location}/twist-libs/*.jar")
dependencies << "#{project_output_location}"
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("#{project_location}", "scenarios")
cmd_args << File.expand_path("#{project_location}", "reports")
cmd_args << File.expand_path("#{project_location}", "twist-conf")
cmd_args << "#{tags}"
cmd_args << "#{threads}"
system (cmd_args.join " ")
raise "Twist tests failed" if $?.exitstatus
end

