Class: Buildr::JtestR
- Includes:
- TestFramework::JRubyBased
- Defined in:
- lib/buildr/java/bdd.rb
Overview
<a href=“jtestr.codehaus.org/”>JtestR</a> is a framework for BDD and TDD using JRuby and ruby tools. To test your project with JtestR use:
test.using :jtestr
Support the following options:
-
:config – path to JtestR config file. defaults to @spec/ruby/jtestr_config.rb@
-
:gems – A hash of gems to install before running the tests.
The keys of this hash are the gem name, the value must be the required version.
-
:requires – A list of ruby files to require before running the specs
Mainly used if an rspec format needs to require some file.
-
:format – A list of valid Rspec –format option values. (defaults to ‘progress’)
-
:output – File path to output dump. @false@ to supress output
-
:fork – Create a new JavaVM to run the tests on
-
:properties – Hash of properties passed to the test suite.
-
:java_args – Arguments passed to the JVM.
Constant Summary collapse
- VERSION =
'0.5'
- STORY_PATTERN =
pattern for rspec stories
/_(steps|story)\.rb$/
- TESTUNIT_PATTERN =
pattern for test_unit files
/(_test|Test)\.rb$|(tc|ts)[^\\\/]+\.rb$/
- EXPECT_PATTERN =
pattern for test files using expectations.rubyforge.org/
/_expect\.rb$/
- TESTS_PATTERN =
[STORY_PATTERN, TESTUNIT_PATTERN, EXPECT_PATTERN] + RSpec::TESTS_PATTERN
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(task, options) ⇒ JtestR
constructor
:nodoc:.
- #runner_config ⇒ Object
- #runner_content(binding) ⇒ Object
-
#tests(dependencies) ⇒ Object
:nodoc:.
- #user_config ⇒ Object
Methods included from TestFramework::JRubyBased
included, jruby_artifact, #jruby_home, #jruby_installed?, #run
Constructor Details
#initialize(task, options) ⇒ JtestR
:nodoc:
349 350 351 352 353 354 355 356 357 |
# File 'lib/buildr/java/bdd.rb', line 349 def initialize(task, ) #:nodoc: super [:test, :spec].each do |usage| java_tests = task.project.path_to(:source, usage, :java) task.compile.from java_tests if File.directory?(java_tests) resources = task.project.path_to(:source, usage, :resources) task.resources.from resources if File.directory?(resources) end end |
Class Method Details
.applies_to?(project) ⇒ Boolean
:nodoc:
334 335 336 337 338 |
# File 'lib/buildr/java/bdd.rb', line 334 def applies_to?(project) #:nodoc: File.exist?(project.path_to(:source, bdd_dir, lang, 'jtestr_config.rb')) || Dir[project.path_to(:source, bdd_dir, lang, '**/*.rb')].any? { |f| TESTS_PATTERN.any? { |r| r === f } } || JUnit.applies_to?(project) || TestNG.applies_to?(project) end |
.dependencies ⇒ Object
325 326 327 328 329 330 331 332 |
# File 'lib/buildr/java/bdd.rb', line 325 def dependencies unless @dependencies super @dependencies |= ["org.jtestr:jtestr:jar:#{version}"] + JUnit.dependencies + TestNG.dependencies end @dependencies end |
Instance Method Details
#runner_config ⇒ Object
378 379 380 381 382 383 384 |
# File 'lib/buildr/java/bdd.rb', line 378 def runner_config runner = super # JtestR 0.3.1 comes with rspec 1.1.4 (and any other jtestr dependency) included, # so the rspec version used depends on the jtestr jar. runner.requires.unshift 'jtestr' runner end |
#runner_content(binding) ⇒ Object
386 387 388 389 |
# File 'lib/buildr/java/bdd.rb', line 386 def runner_content(binding) runner_erb = File.join(File.dirname(__FILE__), 'jtestr_runner.rb.erb') Filter::Mapper.new(:erb, binding).transform(File.read(runner_erb), runner_erb) end |
#tests(dependencies) ⇒ Object
:nodoc:
363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/buildr/java/bdd.rb', line 363 def tests(dependencies) #:nodoc: dependencies |= [task.compile.target.to_s] types = { :story => STORY_PATTERN, :rspec => RSpec::TESTS_PATTERN, :testunit => TESTUNIT_PATTERN, :expect => EXPECT_PATTERN } tests = types.keys.inject({}) { |h, k| h[k] = []; h } tests[:junit] = JUnit.new(task, {}).tests(dependencies) tests[:testng] = TestNG.new(task, {}).tests(dependencies) Dir[task.project.path_to(:source, bdd_dir, lang, '**/*.rb')].each do |rb| type = types.find { |k, v| Array(v).any? { |r| r === rb } } tests[type.first] << rb if type end @jtestr_tests = tests tests.values.flatten end |
#user_config ⇒ Object
359 360 361 |
# File 'lib/buildr/java/bdd.rb', line 359 def user_config [:config] || task.project.path_to(:source, bdd_dir, lang, 'jtestr_config.rb') end |