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

Export Twist Libraries

It is possible to export all the jars that Twist depends on. These jars can then be used to execute scenarios using tools such as Ant, Maven and Rake. The option to Export Twist Libraries is available in the Context Menu of a Twist project.

Using Rake Integration

Here are the steps required to do this:

  1. Export the dependencies of the project into a folder.
  2. 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:
  3. 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