Ben M. wrote:
As the cucumber wiki page says about autotest
(GitHub: Let’s build from here · GitHub) if
you want to override the arguments used by autotest you need to define
an ‘autotest’ profile in your cucumber.yml file. I added information
about profiles here:
GitHub: Let’s build from here · GitHub.
So, in your case you would simply need to create a cucumber.yml file at
the root of your project with this as the contents:
default: -r features
autotest: -r features
(I added the default so that when you use the cli it will automatically
use those args too.)
To answer your original question, you must specify the requiring of the
features dir because cucumber, by default, only loads the ruby files in
the feature’s dir and children dirs. So when you have a feature that is
in a subdirectory of your main features dir you have to explicitly
require the ruby files under features. Make sense?
-Ben
I follow part of this logic, but not all. Given a structure like this:
features
|-- entities
| |-- entity.feature
| -- step_definitions |
– entity_steps.rb
|-- locations
| |-- location.feature
| -- step_definitions |
– location_steps.rb
|-- sites
| -- step_definitions |-- step_definitions |
– webrat_steps.rb
-- support
– env.rb
I would expect that “$ cucumber features” would load all rb files in and
under features abd pre-load the required files before processing the
feature files. If what you are saying is that this command simply sets
up a queue, explicit or implicit, to process .feature files in order of
occurrence whereas the “-r features” argument tells cucumber to
pre-process the .rb files and load all required libraries first then,
yes, your explanation makes sense. Given that it is possible to run
cucumber against a single feature file this is perhaps the only
reasonable way of approaching the problem.
I appreciate your advice with respect to autotest settings. Unhappily,
I had already tried several variants of what you proposed and they all
failed. For example:
$ rake features
…
56 steps passed
$
$ # empty cucumber.yml file
$
$ cat cucumber.yml
$
$ cucumber features -r features
…
56 steps passed
$
$ # cucumber default set
$
$ cat cucumber.yml
default: -r features
$
$ cucumber features
…
14 steps failed
30 steps skipped
12 steps pending
$
$ let us try autotest
$
$ cat cucumber.yml
autotest: -r features
$
$ cat .autotest
require ‘autotest/redgreen’
module Autotest::GnomeNotify
… code to generate popup notice to gnome desktop
Autotest.add_hook :green do |at|
notify SUCCESS_STOCK_ICON, “All Tests Passed.”, “”
end
end
$
$ autotest
loading autotest/cucumber_rails
/usr/bin/ruby -I.:lib:test -rtest/unit -e “%w[test/unit/vendor_test.rb
test/unit/notification_test.rb test/unit/client_test.rb
test/unit/location_test.rb
test/functional/entity_client_controller_test.rb test/unit/site_test.rb
test/functional/clients_controller_test.rb
test/unit/entity_test.rb].each { |f| require f }” | unit_diff -u
Loaded suite -e
Started
…
Finished in 1.85908 seconds.
16 tests, 22 assertions, 0 failures, 0 errors
script/cucumber --profile autotest --format autotest --out
/tmp/autotest-cucumber.6981.0
… some time later…
Interrupt a second time to quit
$
$ # Hmmm. No feature test ran. Let us try this instead.
$ autotest features
loading autotest/cucumber_rails
/usr/bin/ruby -I.:lib:test -rtest/unit -e “%w[test/unit/site_test.rb
test/unit/client_test.rb test/functional/clients_controller_test.rb
test/unit/location_test.rb
test/functional/entity_client_controller_test.rb
test/unit/notification_test.rb test/unit/vendor_test.rb
test/unit/entity_test.rb].each { |f| require f }” | unit_diff -u
Loaded suite -e
Started
…
Finished in 1.666869 seconds.
16 tests, 22 assertions, 0 failures, 0 errors
script/cucumber --profile autotest --format autotest --out
/tmp/autotest-cucumber.6990.0
Nothing happening. No cucumber tests. Lets touch a feature file
from another terminal session
touch features/entity/entity.feature
script/cucumber --profile autotest --format autotest --out
/tmp/autotest-cucumber.6990.1
Ahhh. Something happened. Let us see what is in the output file
cat tmp/autotest-cucumber.6990.1
Nothing.
Interrupt a second time to quit
$ # Let us try something else.
$ cat cucumber.yml
autotest: features -r features
$
$ autotest
loading autotest/cucumber_rails
/usr/bin/ruby -I.:lib:test -rtest/unit -e “%w[test/unit/client_test.rb
test/functional/entity_client_controller_test.rb
test/unit/vendor_test.rb test/functional/clients_controller_test.rb
test/unit/site_test.rb test/unit/entity_test.rb
test/unit/notification_test.rb test/unit/location_test.rb].each { |f|
require f }” | unit_diff -u
Loaded suite -e
Started
…
Finished in 1.674592 seconds.
16 tests, 22 assertions, 0 failures, 0 errors
script/cucumber --profile autotest --format autotest --out
/tmp/autotest-cucumber.7043.0
Feature: Identify and record the location of parties to transactions #
features/locations/location.feature
…
35 steps passed
5 steps failed
16 steps skipped
what happens when we touch a feature file from another session?
script/cucumber --profile autotest --format autotest --out
/tmp/autotest-cucumber.7043.1 -s ‘Test if Fixtures are loaded first’ -s
‘The common name should display with initial capitals’
Feature: Identify and record legal entities associated with a
transaction # features/entities/entity.feature
…
4 steps passed
5 steps failed
16 steps skipped
So, depending upon the way cucumber is invoked, either all the tests
pass, all the tests are skipped, or some of the tests pass and some fail
one way and others pass and fail when invoked another way. This seems
problematic for testing and it is far beyond my modest abilities to
explain or rectify.
Regards,