Gherkin "OR" syntax to reduce repetition with BDD - bdd

Does anyone know of a way to achieve this or do they think it's a good idea. To have an OR style syntax in Gherkin for reducing repetition but maintaining human readability (hopefully). I'm thinking of cases where clause combinations are expanded with every combination of multiple OR statements. e.g.
Scenario: TestCopy
Given Some text is selected
When The user presses Ctrl + C
OR the user right clicks and selects copy
OR the user selects Edit + Copy
Then the text is copied to the clipboard
This would run as 3 tests each with the same given and then but with one When from the OR set. I guess this could have been acheived using a template with a place holder for the When clause but I think this is more readable and could allow the OR to be used in the Given as well to produce n x m tests. With the outline you would still need n x m rows.
Is there a better way to do this
Is it better practice to explicitly copy and paste (I'm thinking maintenance could get messy)
Do other frameworks support this (I think with FIT you could write a custom table but again this seems like overhead)
Thanks.

You can generatd multiple tests from one scenario with Scenario Outlines:
Scenario Outline: TestCopy
Given Some text is selected
When <Copy operation executed>
Then the text is copied to the clipboard
Examples:
| Copy operation executed |
| The user presses Ctrl + C |
| the user right clicks and selects copy |
| the user selects Edit + Copy |
In a Scenario Outline you basically create a template which is filled in the with the provided Examples.
For the the above example Specflow will generate 3 tests with the same Given and Then and with the 3 different Whens:
When The user presses Ctrl + C
When the user right clicks and selects copy
When the user selects Edit + Copy

It's not recommended to use this detail level (pressing these keys, right clicking) on the scenarios. This makes them, as you realize, lengthy and repetitive. Also, that's usually not the information the stakeholders would need or want anyway.
The best would be to hide the implementation details on the step definitions. Your scenario would be something like:
Scenario: TestCopy
Given some text is selected
When the user copies the selected text
Then the selected text is copied to the clipboard
And the different ways of copying the text would go to the 3rd step definition.

As for the n x m scenario, I feel like that when you want to do that, you're probably cuking it wrong.
You didn't give an explicit example, but suppose you want something like:
Given A block of text is selected
OR An image is selected
OR An image and some text is selected
When The user presses Ctrl + C
OR the user right clicks and selects copy
OR the user selects Edit + Copy
Writing your Then clause will be a nightmare.
Instead, try two tests... first, as suggested by #nemesv - but with "text selection" replaced by a generic "selection".
Scenario Outline: TestCopy
Given I have made a selection
When <Copy operation executed>
Then my selection is copied to the clipboard
Examples:
| Copy operation executed |
| The user presses Ctrl + C |
| the user right clicks and selects copy |
| the user selects Edit + Copy |
You can then write a one or more additional tests to deal with "what makes a valid selection" - and this will probably by a feature that you use independent of the copy function - for example, what happens when you make a selection and hit delete... or ctrl-v... or drag and drop?
You don't want to go down the road of multiplying all the valid ways of making a selection against all the valid actions you can take when you've got one.

i'd say that copying and pasting is essentially just making multiple calls to the same method. you are using the same step definititions, so why not just call them multiple times. copy/paste, to me, accomplishes what you want.

Related

want to name the formula in drop down list

in my original workbook i want to display some values from another sheet for multiple actions.. so i put drop down list for each actions. but when the actions increased i couldn't recognize each formulas. (all of them are import range) so that if i can name each formulas in the drop down then i can recognize fast which action to be performed. here a sample sheet is attached for a solution.. pls take a look. in the dropdown list i included (=a2+b2) instead of that if it displayed as addition in drop down list would be help ful. please take a look.
sorry for my english
Any type of help would be appreciated.
https://docs.google.com/spreadsheets/d/1mpIWyQASMlxRVdlTkv9K1e4oihsrckjT6sD1mLDxvEc/edit#gid=0
If I understand correctly, you want to have a dropdown list menu (from Data Validation) that displays the operation name, but when you click it, it displays just the result.
This is very hacky, but here's a way to create some "labels" in your criteria box:
=IF(;"ADDITION";A2+B2),
=IF(;"SUBTRACTION";A2-B2),
=IF(;"DIVISION";A2/B2),
=IF(;"MULTIPLICATION";A2*B2),
How?(!)
After kicking around some no-op ideas, I finally settled on this as the cleanest and most flexible approach. (By some freak coincidence, it also makes some semantic sense too.) It works because when the first argument to IF is omitted, it defaults to 0 -> FALSE. This effectively makes the second argument to IF a comment/no-op, and always just selects the formula.
Yes, the semicolons are intentional or the parser will think of the args as list items.
Productivity Tip/Footnotes
Sheets will remove any line breaks in your validation criteria, so the formula will be hard to read when you have to edit it. If you anticipate that you'll be adding a bunch of functions later, save the above block in a text file and edit that. Then you can copy+paste it into the validation field.
It will also always show up as "INVALID" because the value will of course never match the formula text.

Getting inconsistent tab delimiter width when pasting from Google docs spreadsheet

I am trying to create a gadget for some people, where all they need to do is really copy the contents of a spreadsheet, then paste it in a textbox, which will in turn create a nice table for them to embed in their articles.
I managed to do everything, however Google docs, when copying and pasting data in a text editor, seems to get the size (width) of the tab delimiter wrong between values. So, instead of getting 4 spaces that is the default, i am getting 2 in some cases and so far i managed to find out that the reason is that some of the cells contain strings with spaces. For some reason, this seems to confuse Google docs, thus supplying wrong spacings, which in turn, ruin my script.
I know i can use comma separated values here, but the issue is we are trying to give people the ability to simply copy and paste. Look at the example output below:
School Name Location Type No. eligible pupils
In this example, School Name is one cell, Location is another, Type is another and No. eligible pupils is the last one. It is clear that the first cell does not have the necessary space on the right.
Any ideas? I thought about converting all blank spaces that take more than 1 space to commas, but this might lead to a situation users might actually use 2... which would not work again.
For some reason, it was the code editor that was actually not showing the tabs right. Using a regexp and another code editor (vim) showed that all of them were actual tabs. :)

Generating values for dropdown ONLY for 'C' of CRUD

When choosing 'Add' in CRUD, how best to generate a list of choices to pick from a dropdown?
For U/update - just display what's there...
The field contents starts with a letter, followed by five numeric digits:{A-I,K-N,Z}#####
Each letter has a different 'max' value for the numeric part.
So when adding a new record, I'd like to offer a listbox with one of each letter and that letter's highest numeric value + 10.
So, if the max 'A' as A00120, and max 'B' B00030 (etc) the listbox would have A00130 and B00040.. etc
Save the user having to figure out which is 'next' when generating a new record.
? Thanks,
Mark
This time I'll not be able to come up with ready to use solution, but I must say - everything is possible with ATK4. You just have to customize and extend it to fit your needs :)
Speaking about your question above - I guess you have to split it in multiple parts.
First part is about how to show select box on Create and readonly or disabled field on Update. I guess you can make some custom Form field or pin some action to existing Form Field hook. Not sure exactly what's better in this case.
Second one is about data structure. I believe that this field actually should be 2 fields in DB and maybe (only maybe) merged together in ATK model with addExpression() just for user interface needs to display these 2 fields as one field easily in UI. Maybe such concatenated field will be useful also for searching, but definitely not as only one field stored in DB. Imagine how hard it'll be for DB engine to find max value if such field. Store it like type = letter, num = number and then search like SELECT max(num)+10 FROM t WHERE type='A'
Finally Third part is about how to generate this next number. I read your question 3 times and came to conclusion that actually you don't have to show this +10 numeric value in UI at all if it's hardly predefined anyway. Actually that'll not work correctly if this will be multi-user system which I guess it will. Instead just show simple select box with letters {A-I,K-N,Z} and calculate this next value exactly before inserting data in DB. That can be done using models insert hook. This will be much more appropriate solution and will be better for UI and also more stable because calculated in model not incorrectly in UI part.

Dynamic Search Boxes in Jquery Mobile

Am not sure on how to do this but I will describe it and hopefully you all can come up with a good solution. I want to have a box (not sure if its an input of search box) that when someone types in the box it pulls values from my database and shows the closest match based on characters being typed in. If the word that is typed by the user is not there then when the form is submitted then the word is added to a database.
Additionally I want to have an add button next to the box, so that if the user wants to add more than one word they can. This means that when the add is clicked a duplicate of the first box appears which does the same thing. The values will be stored in an array.
Any idea how I can go about doing this?

Automatically updating Data Validation lists based on user input

I have a very large data set (about 16k rows). I have 10 higher level blocks and within each block I have 4 categories (10 rows for each) which use Data Validation lists to show items available in each category. The lists should automatically update based on user input. What I need your help with is that I want to use the same data set for each block and preferably a least calculation/size intensive approach. I have put together a sample file that outlines the issue with examples.
Sample File
Thank you for your help in advance.
Okay, I've found something, but it can be quite time consuming to do.
Select each range of cells. For instance, for the first one, select B3:B18 and right click on the selection. Find 'Name a Range..." and give it the name "_FIN_CNY". Repeat for all the other ranges, changing the name where necessary.
Select the first range of cells to get the data validation, and click on "Data validation", pick the option "Allow: List" (you already have it) and then in the source, put the formula:
=INDIRECT($G$4&"_CNY")
$G$4 is where the user will input. This changes as you change blocks.
_CNY is the category. Change it to _CNY2 for the second category.
Click "OK" and this should be it. Repeat for the other categories.
I have put an updated file on dropbox where you can see I already did it for the data of _FIN for categories CNY, CNY2 and INT and did the one for _GER as well. You'll notice the category of INT for _GER doesn't work, that's because the Named Range _GER_INT doesn't exist yet.

Resources