I'm playing with cucumber but for some reason the features and scenarios are not being outputted to the console.
When I run
cucumber features
I get
Using the default profile...
....
1 scenario (1 passed)
4 steps (4 passed)
0m0.071s
So my tests have passed but I can't see my features or scenarios. Is there a command line flag or something?
Yes, you can use -f pretty resp. --format pretty.
I really like the html output too, especially when debugging my step definitions:
cucumber features -f html -o "path/to/some/file.html"
Related
How do I tell Taurus that my (Postman/Newman) test is a Blazemeter Functional test, and not a Performance test? Below is my bzt.yaml I created with the help of https://gettaurus.org/docs/Postman/.
execution:
- executor: newman
iterations: 1
scenario: functional/simple
scenarios:
functional/simple:
script: my.postman_collection.json
reporting:
- module: blazemeter
modules:
blazemeter:
request-logging-limit: 20240
public-report: false
report-name: my-postman-collection
test: newmantrials
project: test
final-stats:
summary-labels: true
I run it using the taurus Docker image:
docker run --rm -t -v `pwd`:/bzt-configs -v `pwd`/artifacts:/tmp/artifacts blazemeter/taurus:1.14.0 bzt.yaml -o modules.blazemeter.token="${token}"
When I log into the Blazemeter UI, I see that it's listed under the "Performance" tab, and looks like a performance test. I would like it to run as a Functional test to get more details on the request and response payloads.
I do not believe it's possible at the moment, because presently BlazeMeter functional tests are geared toward either straight API functional tests or GUI (Selenium) functional tests.
The problem is that from BlazeMeter's side, the file validator is failing to correctly identify the Postman/Newman JSON file (despite the YAML file referencing it properly). I reported this to the BlazeMeter R&D team fairly recently, so it's being looked into.
In the meantime though, I don't expect this to work in BlazeMeter. It likely won't correctly identify your Newman script unless you run it as a Performance test for the interim.
(Sorry for the bad news on this one -- Hopefully it'll get sorted soon!)
Feel free to bring this up with BlazeMeter support at support#blazemeter.com as well.
What is rails test command to exclude some test files or test name to be run?
For example, I want to exclude 1 rb test file which is test/integration/trello_webhook_test.rb
I have try this commands:
rails test -t --ignore-testcase= "test/integration/trello_webhook_test.rb"
I give another try to exclude my test name contained "JSON" in trello_webhook_test.rb with this command:
rails test -t --ignore-name= "/JSON/"
But, both commands result in the test of trello_webhook_test.rb or the test name contained "/JSON/" was still run.
Thanks in advance for any response.
the rails test --help:
rails test --help output
I'm using Windows 10 OS.
Best,
Randy
According to help manual (rails test --help) you have to do:
rails test --exclude test/integration/trello_webhook_test.rb
When calling rspec from the command line, I know that you can use the -e or -example flag to pass in a regex which it matched against the content of any it blocks, but is there a way to pass in a regex and have RSpec run files whose names match that regex?
You can use for examples :-
It will load for you all files, whose names start with test
rspec -P spec/**/test*_spec.rb
rspec -P spec/**/test*.rb
It will load for you all files, which has a word test in middle, but not start with test
rspec -P spec/**/*?test*_spec.rb
It will run all files whose name start with test. Like test_1_spec.rb, test_2_spec.rb etc. But you have to run this command from your project root directory.
Docs for -P / --pattern flag
Information can also be obtained from --help
arup$ rspec -help | grep PATTERN
-P, --pattern PATTERN Load files matching pattern (default: "spec/**/*_spec.rb").
You can use bash expansion. It isn't as powerful as a full regex but works most of the time. So you can do things like
rspec spec/models/user_*.spec
Docs here: https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html#Pattern-Matching
As title says, my travis-ci instance is telling me that my build is failing when I have cucumber step definitions that are pending (not undefined) - is there a way to stop this behaviour?
I can understand the reason why, but the undefined behaviour I have is undefined by purpose - I have no intention on doing that feature RIGHT NOW, but I know I want to keep the step definition down so I don't forget what I came up with. The reason I ask is because this behaviour (with it failing when I have a pending task) could end up masking real failures that actually matter.
There is a similar answer here which should be useful for you, the answer that he gives is:
I think cucumber gives non-zero process exit code either because of
skipped or because of pending tests. Try to get it to not run any
skipped, then any pending, then any skipped or pending tests and see
what exit codes it gives. To see the exit code (in Unix), run it with
something like:
cucumber ...args to select tests... ; echo $?
So basically you want to figure out what args you can provide to cucumber to have it pass and then provide a .travis.yml that runs that command. an example rake task for cucumber jasmine and rspec is here:
task :travis do
["rspec spec", "rake jasmine:ci", "rake cucumber"].each do |cmd|
puts "Starting to run #{cmd}..."
system("export DISPLAY=:99.0 && bundle exec #{cmd}")
raise "#{cmd} failed!" unless $?.exitstatus == 0
end
end
And read the docs for more info on creating a .travis.yml.
If all of that doesn't work, just create a bash script that catches the output and returns 0 in the right cases, I really doubt this is required though since I'm sure there's an option to cucumber to make it ignore pending.
EDIT: the cucumber docs say:
Pending steps
When a Step Definition’s Proc invokes the #pending method, the step is
marked as yellow (as with undefined ones), reminding you that you have
work to do. If you use --strict this will cause Cucumber to exit with
1.
Which seems to imply that they will not exit with 0 if you don't call --strict
Is there a cucumber command that will print out just the feature info and the scenario names?
I recently began a project and want to print out the cucumber features and scenarios I wrote to describe the scope of the project and get it confirmed with the client.
Do you mean cucumber -d?
$ cucumber -h
-d, --dry-run Invokes formatters without executing the steps.
This also omits the loading of your support/env.rb file if it exists.
Implies --no-snippets.
Implies --dry-run --formatter pretty.