cucumber command that will print out just the feature and scenario names - ruby-on-rails

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.

Related

Specify Taurus test as a Blazemeter Functional test

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?

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

Is It Possible To Pass A regex to the 'rspec` Command line command?

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

Rails: Automatically running failed tests

I frequently run "rake", see some tests fail, and have to manually cut-and-paste failures into a new command, "ruby SomeTest -n some_test_method" to run individual tests. Is there any way to automate that?
It feels like standard behaviour for IDEs to show errors and allow quick re-playing, so I wonder if anyone has figured out how to do it quickly on the command line.
Guard is what you're looking for:
https://github.com/guard/guard
Guard watches the filesystem for changes and automatically triggers a command. With guard you can automatically run tests the second they're saved.
For minitest use:
https://github.com/guard/guard-minitest
For test unit:
https://github.com/guard/guard-test
For Rspec:
https://github.com/guard/guard-rspec

Cucumber not outputting to the console

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"

Resources