1class MultiThreadedExampleGroupRunner < Spec::Runner::ExampleGroupRunner
2 def initialize(options, arg)
3 super(options)
4 # configure these
5 @thread_count = 4
6 @thread_wait = 0
7 end
8
9 def run
10 @threads = []
11 q = Queue.new
12 example_groups.each { |b| q << b}
13 success = true
14 @thread_count.times do
15 @threads << Thread.new(q) do |queue|
16 while not queue.empty?
17 example_group = queue.pop
18 success &= example_group.suite.run(nil)
19 end
20 end
21 sleep @thread_wait
22 end
23 @threads.each {|t| t.join}
24 success
25 end
26end
27
28MultiThreadedBehaviourRunner = MultiThreadedExampleGroupRunner