C0 code coverage information
Generated on Wed Oct 07 08:33:59 -0700 2009 with rcov 0.8.2.1
Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements. See the NOTICE file distributed with this
3 # work for additional information regarding copyright ownership. The ASF
4 # licenses this file to you under the Apache License, Version 2.0 (the
5 # "License"); you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations under
14 # the License.
15
16
17 module Buildr::Groovy
18
19 # EasyB is a Groovy based BDD framework.
20 # To use in your project:
21 #
22 # test.using :easyb
23 #
24 # This framework will search in your project for:
25 # src/spec/groovy/**/*Story.groovy
26 # src/spec/groovy/**/*Specification.groovy
27 #
28 # Support the following options:
29 # * :format -- Report format :txt or :xml, default is :txt
30 # * :properties -- Hash of properties passed to the test suite.
31 # * :java_args -- Arguments passed to the JVM.
32 class EasyB < TestFramework::JavaBDD
33 @lang = :groovy
34 @bdd_dir = :spec
35
36 VERSION = "0.9"
37 TESTS_PATTERN = [ /(Story|Specification).groovy$/ ]
38 OPTIONS = [:format, :properties, :java_args]
39
40 class << self
41 def version
42 Buildr.settings.build['jbehave'] || VERSION
43 end
44
45 def dependencies
46 @dependencies ||= ["org.easyb:easyb:jar:#{version}",
47 'org.codehaus.groovy:groovy:jar:1.5.3','asm:asm:jar:2.2.3',
48 'commons-cli:commons-cli:jar:1.0','antlr:antlr:jar:2.7.7']
49 end
50
51 def applies_to?(project) #:nodoc:
52 %w{
53 **/*Specification.groovy **/*Story.groovy
54 }.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
55 end
56
57 private
58 def const_missing(const)
59 return super unless const == :REQUIRES # TODO: remove in 1.5
60 Buildr.application.deprecated "Please use JBehave.dependencies/.version instead of JBehave::REQUIRES/VERSION"
61 dependencies
62 end
63 end
64
65 def tests(dependencies) #:nodoc:
66 Dir[task.project.path_to(:source, bdd_dir, lang, "**/*.groovy")].
67 select { |name| TESTS_PATTERN.any? { |pat| pat === name } }
68 end
69
70 def run(tests, dependencies) #:nodoc:
71 options = { :format => :txt }.merge(self.options).only(*OPTIONS)
72
73 if :txt == options[:format]
74 easyb_format, ext = 'txtstory', '.txt'
75 elsif :xml == options[:format]
76 easyb_format, ext = 'xmlbehavior', '.xml'
77 else
78 raise "Invalid format #{options[:format]} expected one of :txt :xml"
79 end
80
81 cmd_args = [ 'org.disco.easyb.BehaviorRunner' ]
82 cmd_options = { :properties => options[:properties],
83 :java_args => options[:java_args],
84 :classpath => dependencies }
85
86 tests.inject([]) do |passed, test|
87 name = test.sub(/.*?groovy[\/\\]/, '').pathmap('%X')
88 report = File.join(task.report_to.to_s, name + ext)
89 mkpath report.pathmap('%d')
90 begin
91 Java::Commands.java cmd_args,
92 "-#{easyb_format}", report,
93 test, cmd_options.merge(:name => name)
94 rescue => e
95 passed
96 else
97 passed << test
98 end
99 end
100 end
101
102 end # EasyB
103
104 end
105
106 Buildr::TestFramework << Buildr::Groovy::EasyB
Generated using the rcov code coverage analysis tool for Ruby
version 0.8.2.1.