fitnesse: howto load a symbol with a result in query table - fitnesse

In a FitNesse query table, is it possible to load a symbol with the returned results?
example of what I would like to do:
|Query: GetPlayers|
| name | age | ID |
| jones | 36 | $ID1= |
| smith | 27 | $ID2= |
Or alternatively, just have one $ID symbol which is loaded with a collection.
Is this possible?

Unfortunately I believe this is still an unresolved issue in FitNesse. There is a PivotalTracker entry for it, that no one has take one yet: https://www.pivotaltracker.com/story/show/1893214. I've looked at it, but haven't been able to solve it myself.
We currently work around this by having a driver that can do equivalent query. Then we get the value back from the query. It is much more cumbersome, but works for now.
I completely agree that this should be possible. But as far as I know, it has not been fixed yet.

Maybe I don't understand your problem, but this is working fine for me:
|Query: whatever|whatever_param |
|key |value |
|a_key |$symbol= |
|check |$symbol|a_value|
I use Cslim, and the method whatever.query() returns a list of maps that correspond to the keys (the key a_key have the value a_value for this exemple)

Related

What is the proper way to "store" data with PowerShell

I have to handle quite a lot of results and store them. I'd like to create something like a tab which I could in the end export as a CSV.
I was using a PSObject with quite a lot of members. I wonder if there is a better way to handle this? If you can show me how to create it and input data it would be nice.
I should create a tab witch look like this:
Site 1 | Tester | result Test 1 | Result test 2 |.... |Result test x
Sitename1 | tester1| Fail | Succes | fail| etc...
Sitename1 | tester1| Succes | Fail | fail| etc...
PS: It has to be working with PowerShell v2.0.

query for passive hosts to be removed?

Can someone please help me to remove passive hosts in splunk. the query i am using is:
| metadata type=hosts
| sort recentTime
| convert ctime(recentTime) as Latest
You should compare the recentTime with the current time, work out the difference and compare the difference with a threshold to identify those hosts
Example query:
| metadata type=hosts | eval diff=now()-recentTime | eval threshold=3600 | where diff>threshold
Note: query not tested but you should get the idea

Repeating steps with different values in BDD test case

I am new to BDD specflow.
I have to write a scenario wherein after I capture an image, i have to select a value for each defined attribute for that image from a selection list
For Eg:
|Body Part |Location |Group |
| Leg | Left | Skin |
| Hand | Upper | Burn |
| Arm | Right | Ulcer |
I need a way in which i can select a different value for each attribute, every time.
Thanks in advance!
You are looking for Scenario Outline;
Scenario outlines allow us to more concisely express these examples through the use of a template with placeholders, using Scenario Outline, Examples with tables and < > delimited parameters.
Specflow takes each line in the Example table and create from the line a scenario to execute.

cannot find "for loop" keyword in robot framework

I am currently connecting SQL server to robot framework, so i can read my data table name in robot. and I want to use for loop to check table name, somehow, ":FOR" loop keyword cannot found, but I have installed libraries such as operating-system, collections, string, built-in, diff-library and so on. anyone can help me why i cannot use for loop? any help will be appreciated.
The robot framework users guide has a whole section on how to use the for loop. From that section:
The syntax starts with :FOR, where colon is required to separate the
syntax from normal keywords. The next cell contains the loop variable,
the subsequent cell must have IN, and the final cells contain values
over which to iterate. These values can contain variables, including
list variables.
Here's an example from the user's guide, reformatted to use pipes (for clarity):
*** Test Cases ***
| Example 1
| | :FOR | ${animal} | IN | cat | dog
| | | log | ${animal}
| | | log | 2nd keyword
| | Log | Outside loop
Maybe you are not escaping indented cells; as the Tip in the documentation says. Try writing loops like this:
:FOR ${index} IN RANGE ${start} ${stop}
\ log to console index: ${index}
\ Call a Keyword

Scenario Outline: Placeholders with a restricted number of possible values

I am relatively new to BDD and I have a question regarding scenario outlines. When looking at samples over the internet I have the feeling that the placeholders can take any values. The number of elements in their domain is not restricted. Here is one example:
Scenario Outline: eating
Given there are <start> cucumbers
When I eat <eat> cucumbers
Then I should have <left> cucumbers
Examples:
| start | eat | left |
| 12 | 5 | 7 |
| 20 | 5 | 15 |
The placeholder <start> for example can be any number so the number of values is infinite.
In my specs I have to deal with contracts which can have one of four states (planned, ongoing, paused, and closed). My specs say that I can edit planned contracts but I am not allowed to edit contracts which have one of the remaining three states.
I think I would write a scenario named "Updating a planned contract" and one scenario outline where the status of a contract is a placeholder.
Scenario: Update a planned contract
Given the list of contracts as follows
| name | status | some value |
| c1 | planned | 123 |
And I have edited contract c1 as follows
| field | value |
| name | c1 |
| some value | 456 |
When I save contract c1
Then the list of contracts should be as follows
| name | status | some value |
| c1 | planned | 456 |
Scenario Outline: Update contract
Given there is a <status> contract
And I have edited that contract
When I save that contract
Then I an error 'only planned contracts are allowed to change' should be displayed
Examples:
| status |
| ongoing |
| paused |
| closed |
Is that the right way? One expicit scenario and one parameterized? Or should I write the scenario outline as explicit scenarios for each possibility? I am not sure because the status of a contract is restricted by four possible values as opposed to the examples on the internet.
One thing I find that helps is to remember that Gherkin is just a syntax for Specification by Example. You are trying to provide the examples that make most sense to you in the business domains language.
As such, what you are proposing is perfectly valid. You have one example of a scenario that uses tables to define what happens when a planned contract is edited, and another set of examples that produce errors when contracts in other states. You could also do it explicitly by expanding the outline for each state. Both are valid, and you can always refactor your feature sepcifications as you would the codebase.
What you are aiming to do here however is to provide a grammar, a framework, a language, call it what you will, that you can use to have conversations with your business analysts. You want to be able to pull out this document and say "This is how the system works now, how do we change this to make it support your new feature?".
Personally, I'm avoiding tabular and outline forms in my features right now as I want to make it look as friendly as possible to all I show it to, and as yet, my features are still easy to describe.

Resources