Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
115 lines (68 sloc) 3.53 KB

Always Be Testing!!!

A test framework that uses IronWorker to run it... constantly.

Read this blog post for background: When Unit Tests Aren't Enough... ABT - Always Be Testing.

Getting Started

First of all, the code to test must be able to check for a special config variable:

if defined? $abt_config
  @config = $abt_config

A real world example of using $abt_config is here:

Upload worker

iron_worker upload

Or (if you want to customize smth)

git clone
iron_worker upload abt

Get it running

Using CLI

iron_worker queue abt -p "{\"git_url\":\"git://\",\"test_config\":{}}"

Using code(check queue.rb):

require 'iron_worker_ng'
client = => 'TOKEN', :project_id => 'PROJECT_ID')
params = {
      "git_url" => 'git://',
      "parameters" => ['--name=/test_performance.*/'],
      "test_config" => {}}

client.tasks.create('abt', params)

Add built in notifier (optional):

Using CLI

iron_worker queue abt -p "{\"notifiers\":[{\"class_name\":\"HipChatNotifier\", \"config\":{\"token\":\"HIPCHAT_TOKEN\", \"room_name\":\"AlwaysBeTesting\", \"important_room_name\":\"RoomName\", \"user_name\":\"ABT Worker\"}}], \"git_url\":\"git://\", \"test_config\":{}}}"

Using code(check queue.rb):

params.merge! {"notifiers" => [{"class_name"=>"HipChatNotifier",

you can add as many notifiers as you need and even make your own (read down for how to build custom notifiers).

Schedule It!

Schedule it to run regularly to ensure you're always being covered.

Using CLI

iron_worker schedule --start-at "2013-01-01T00:00:00-04:00" --run-every 600 --payload  "{\"git_url\":\"git://\",\"test_config\":{}}"

Using code

client.schedules.create('abt', params, {:start_at =>,:run_every=>600})

Custom notifiers

Here's how to build your own notifiers.

Implement in your notifier the following methods:

setup configuration:

def initialize(config)
  @url = config["url"]

process simple text message

def send_message(message)
  puts message

if you want more detailed results, 'result' is an instance of Test::Unit::TestResult

def send_formatted_message(result)

Then to use it:

worker.add_notifier(File.join(File.dirname(__FILE__), 'console_notifier'), :class_name=>'ConsoleNotifier', :config={})

Custom unit-test command line options

filter test methods by pattern:

"parameters" => ['--name=/test_performance.*/']