How to skip Cucumber steps? - cucumber

I have the scenario like:
Given I go to this page
When I type cucumber
And I click
Then I should see the text
And I should not see the line
If I run this scenario it will execute all the 5 steps. But I want to skip the 4th step (Then I should see the text) and execute the 5th step.
Please give me your suggestions. Thanks in advance. :)

TL;DR - don't do it - you're (probably) getting it wrong. And you can't (easily) do it. As Aslak wrote (one of Cucumber main creators):
A step can have the following results:
undefined (no matching stepdef)
pending (a matching stepdef that throws PendingException)
passed (a matching stepdef that doesn't throw anything)
failed (a matching stepdef that throws an exception that isn't PendingException)
skipped (a step following a step that threw any exception (undefined, pending or failed))
What you're asking for is a new kind of result - ignored. It could be
implemented by throwing an IgnoredException. This would mean that
skipped would have to be changed to: (a step following a step that
threw any exception (undefined, pending or failed) - unless the
exception was IgnoredException)
I'm not sure I like this. It sounds like more complicated than it
needs to be. You already have the necessary information that something
is amiss - your step will either fail or be pending. I don't see the
value in continuing to execute the following steps. You still have to
implement the failing/pending step.
As long as you're reminded that "there is work to be done here" I
don't think it's wortwhile complicating Cucumber to tell you what kind
of work needs to be done...
Aslak
Whole discussion is here: http://comments.gmane.org/gmane.comp.programming.tools.cucumber/10146

I have had to skip steps conditionally based on environments. I used next to skip steps. Here is an example on how to do what you wanted.
Then /^I should see the text/$ do
next if #environment == 'no text'
...
<The actual step definition>
...
end

Related

correct REST API for autosuggest on google?

I feel silly asking this.. but its doing my head..
if I use 'https://maps.googleapis.com/maps/api/place/autocomplete/json' and set the input parameter to say - 'Palazzo Cast' I will get about 5 suggestions - none of which will be the one I'm looking for. if I set input to 'Palazzo Castellania' I will get zero results - even though there is a place called this (see below). I've set the region parameter to 'mt'...
If I use 'https://maps.googleapis.com/maps/api/place/findplacefromtext' and set the input parameter to 'Palazzo Castellania' - I will get 'the Ministry of Health' - which is correct - however, if I put a partial string in I'll get only a single candidate which will be something different - there doesn't seem to be a way to get multiple place candidates?
I'm guessing from an API side - I have to do a multi-step process - but it would be good to get some input.
My thoughts:
I start with 'https://maps.googleapis.com/maps/api/place/autocomplete/json' - if I get an empty result, I try 'https://maps.googleapis.com/maps/api/place/findplacefromtext'
if I get a single result from either then I can pass the placeID to the places API to get more detailed data.
Make sense? It feels argly..
Edit
So watching how https://www.google.com.mt/ does it... while typing it uses suggest (and never gives the right answer, just like the API) and then when I hit enter it uses search and gives the correct answer... leading me to the conclusion that there is actually two databases happening!
Basically "its by design".. there is no fix as of Feb 2023.. My thoughts are to cache results and do a first search against that otherwise I'll probably use bing or here

Logic APP : ActionFailed. An action failed. No dependent actions succeeded

I am facing the issue with for loop execution with logic APP in azure. Apparently complete playbook execute successfully and functionally its working good. However, i am getting this error because it takes "body" parameter from previous step as input and nothing else. The body is long json and therefore should not be the right input for foreach loop. I tried adding account or Ip address as input but that fails as well.
Input
Output
Please help here
As you mentioned there is just one item in your json data array which contains "MachineId", I assume the first item contains "MachineId". Please refer to the solution below, it will help you to use the only "MachineId" in the 24 cycles of your loop.
We can input an expression to use the "MachineId" in first item:
body('Parse_JSON')[0].MachineId
(In the screenshot above, I just use a "Set variable" to replace your two actions in "For each" loop, but I think there is no difference between them)
Please have a try with this solution~

Equivalent of String.Format in a Chef/Bash Recipe

looking for something similar to .Net string format in a chef recipe ie.
string phone = String.format("phone: {0}",_phone);
I have a Chef recipe where I need to build up a command string with 30 of these params so hoping for a tidy way to build the string, in principle Im doing this
a=node['some_var'].to_s
ruby_block "run command" do
block do
cmd = shell_out!("node mycommand.js #{a}; exit 2;")
end
end
When I try this I get the error
Arguments to path.join must be strings any tips appreciated
Chef runs in two phases:
Compile and Execute (see https://www.chef.io/blog/2013/09/04/demystifying-common-idioms-in-chef-recipes/ for more details).
Your variable assignment to a happens at compile time, e.g. when chef loads all recipes. The ruby block will be execute in execution mode at converge time and cannot access the variable a.
So the easiest solution might be putting the attribute into the ruby block:
ruby_block "run command with argument #{node['some_var']}" do
block do
shell_out!("node mycommand.js #{node['some_var']}")
end
end
However:
If you don't need to execute Ruby code, consider using the execute or bash resource instead.
Keep in mind, that you must have a unique resource name, if you're building some kind of loop around it. An easy way is to put something unique into the name ruby_block "something unique per loop iteration" do ... end
What I really don't understand is your exit code 2. This is an error code. It will make chef throw an exception each time. (shell_out! throws an exception if exit code != 0, see https://github.com/chef/chef/blob/master/lib/chef/mixin/shell_out.rb#L24-L28)
The resource will be executed on each chef run. This is probably not in your interest. Consider adding a guard (test), to prevent unnecessary execution, see https://docs.chef.io/resource_common.html#guards

Procedure was expanded as instream procedure definition

I am a newbie to mainframes and JCl. I am getting the error:
"Procedure was expanded as instream procedure definition"
this is my JCL.
I am getting the message IEFC001I . Somone please help me to solve this issue.
I think the title of this question should be renamed to What means IEFC001I message "Procedure was expanded as instream procedure definition"? Even though you seem to have forgotten to include your JCL (as per your "This in my JCL"), I don't think there is a need for including such JCL to be able, to answer your question.
When a JCL is submitted, the job that starts running may result in a message like so:
Procedure was expanded as instream procedure definition
The message identifier related to that message is IEFC001I. Note the "I" at the end of this message, which stands for something like "Informational only" (instead of "E" for error, or "A" for Abend"). So this is not to be considered as an error.
What it is actually trying to say, is that your JCL contained the details of some "procedure", which in this case was added to the JCL itself (= instream). An alternative could have been that some JCL jobstep was executing a procedure, with a member that can be found in one of the typical libraries where lots of such procedures are located also, like DSN=SYS1.PROCLIB .
Note: as a variation to using "instream procedures", you may also want to use the "JCLLIB ORDER = ..." statement. That allows you to specify 1 or more DSNs in which you want you r JCL to go look for any proclib members you are using in your JCL. I often use that technique when I'm testing an updated procedure member (before actually installing it in the "official proclib DSNs", and which is used if you do not specify any such JCLLIB ORDER ...

How can I make cucumber run all the steps (not skip them) even if one of them fails?

I am using Cucumber with RubyMine, and I have a scenario with steps that verify some special controls from a form (I am using cucumber for automation testing). The controls don't have anything to do with each other, and there is no reason for the steps to be skipped if one in front of them fails.
Does anyone know what configurations or commands should I use to run all the steps in a scenario even if they all fail?
I think the only way to achieve desired behavior (which is quite uncommon) is to define custom steps and catch exceptions in it yourself. According to cucumber wiki step is failed if it raises an error. Almost all default steps raise error if they can't find or interact with an element on the page. If you'll catch this exceptions the step will be marked as passed, but in rescue you can provide custom output. Also I recommend you to carefully define exceptions you want to catch, I think if you're Ok if selenium can't find an element on the page rescue only from ElementNotFound exceptions, don't catch all exceptions.
I've seen a lot of threads on the Web about people wanting to continue steps execution if one failed.
I've discussed with Cucumber developers: they think this is a bad idea: https://groups.google.com/forum/#!topic/cukes/xTqSyR1qvSc
Many times, scenarios can be reworked to avoid this need: scenarios must be split into several smaller and independent scenarios, or several checks can be aggregated into one, providing a more human scenario and a less script-like scenario.
But if you REALLY need this feature, like our project do, we've done a fork of Cucumber-JVM.
This fork let you annotate steps so that when they fail with a determined exception, they will let let next steps execute anyway (and the step itself is marked as failed).
The fork is available here:
https://github.com/slaout/cucumber-jvm/tree/continue-next-steps-for-exceptions-1.2.4
It's published on the OSSRH Maven repository.
See the README.md for usage, explanation screenshot and Maven dependency.
It's only available for the Java language, tough: any help is welcome to adapt the code to Ruby, for instance. I don't think it will be a lot of work.
The question is old, but hopefully this will be helpful. What I'm doing feels kind of "wrong", but it works. In your web steps, if you want to keep going, you have to catch exceptions. I'm doing that primarily to add helpful failure messages. I'm checking a table full of values that are identified in Cucumber with a table having a bunch of rows like:
Then my result should be:
| Row Identifier | Column Identifier | Subcolum Identifier | $1,247.50 |
where the identifiers make sense in the application domain, and name a specific cell in the results table in a human-friendly way. I have helpers that convert the human identifiers to DOM IDs, which are used to first check whether the row I'm looking for exists at all, then look for the specific value in a cell in that row. The default failure message for a missing row is clear enough for me (expected to find css "tr#my_specific_dom_id" but there were no matches). But the failure message for checking specific text in a cell is completely unhelpful. So I made a step that catches the exception and uses the Cucumber step info and some element searching to get a good failure message:
Then /^my application domain results should be:$/ do |table|
table.rows.each do |row|
row_id = dom_id_for(row[0])
cell_id = dom_id_for(row[0], row[1], row[2])
page.should have_css "tr##{row_id}"
begin
page.should have_xpath("//td[#id='#{cell_id}'][text()=\"#{row[3].strip.lstrip}\"]")
rescue Capybara::ExpectationNotMet => exception
# find returns a Capybara::Element, native returns a Selenium::WebDriver::Element
contents = find(:xpath, "//td[#id='#{cell_id}']").native.text
puts "Expected #{ row[3] } for #{ row[0,2].join(' ') } but found #{ contents } instead."
#step_failures_were_rescued = true
end
end
end
Then I define a hook in features/support/hooks.rb like:
After do |scenario|
unless scenario.failed?
raise Capybara::ExpectationNotMet if #step_failures_were_rescued
end
end
This makes the overall scenario fail, but it masks the step failure from Cucumber, so all the step results are green, including the ones that aren't right. You have to see the scenario failure, then look back at the messages to see what failed. This seems kind of "bad" to me, but it works. It's WAY more convenient in my case to get the expected and found values listed in a domain-friendly context for the whole table I'm checking, rather than to get a message like "I looked for "$123.45" but I couldn't find it." There might be a better way to do this using the Capybara "within" method. This is the best I've come up with so far though.

Resources