Does specflow provide a way to get data from the "Examples" table when using the scenario outline format? Similar to how tags are available in scenario context during execution.
No, there is no way for that.
The examples you write into the examples table are like parameter for a scenario.
These values are replaces the placeholder in your scenario steps (they are in <> brackets)
Example from the Gherkin documentation (https://cucumber.io/docs/reference - Scenario Outline)
Scenario Outline: feeding a suckler cow
Given the cow weighs <weight> kg
When we calculate the feeding requirements
Then the energy should be <energy> MJ
And the protein should be <protein> kg
Examples:
| weight | energy | protein |
| 450 | 26500 | 215 |
| 500 | 29500 | 245 |
| 575 | 31500 | 255 |
| 600 | 37000 | 305 |
You can only get the whole table, if you are using a data table as parameter.
Example:
Given the following users exist:
| name | email | twitter |
| Aslak | aslak#cucumber.io | #aslak_hellesoy |
| Julien | julien#cucumber.io | #jbpros |
| Matt | matt#cucumber.io | #mattwynne |
You can access this with this binding:
[Given(#"the following users exist:")
public void TheFollowinUsersExists(Table table)
{
//your code
}
Related
The following code is my Scenario:
Scenario: TradeOrders
Given Order 'SellOrder' Has Been Registerd
| Side | Price | Amount | IsFillAndKill | ExpireTime |
| 0 | 100 | 5 | false | 2024-02-05 09:30:26.2080000 |
And Order 'BuyOrder' Has Been Defined
| Side | Price | Amount | IsFillAndKill | ExpireTime |
| <Buy> | <Price> | <Amount> | <IsFillAndKill> | <ExpireTime> |
When I Register The Order 'BuyOrder'
Then The following 'Trade' will be created
| BuyOrderId | SellOrderId | Amount | Price |
| <BuyOrderId> | <SellOrderId> | <TradeAmount> | <TradePrice> |
And BuyOrder 'BuyOrder' Should Be Modified like this
| Side | Price | Amount | IsFillAndKill | ExpireTime |
| 1 | 100 | 0 | false | 2024-02-05 09:30:26.2080000 |
Examples:
| Buy | Price | Amount | IsFillAndKill | ExpireTime |
| 1 | 100 | 5 | false | 2024-02-05 09:30:26.2080000 |
Examples:
| <BuyOrderId> | <SellOrderId> | <TradeAmount> | <TradePrice> |
| 1 | 2 | 5 | 100 |
I want to add some examples with different columns but I have faced with below error:
Severity Code Description Project File Line Suppression State
Error Generation error: Message: The example sets must provide the
same parameters.
I appreciate you in advance.
This is not supported in SpecFlow. Since both tables are used in the same scenario, they need to go in the same row. It makes for a wide table, but there isn't anything you can do about it. Second of all, you cannot have < or > tokens in the column headers.
Examples:
| Buy | Price | Amount | IsFillAndKill | ExpireTime | BuyOrderId | SellOrderId | TradeAmount | TradePrice |
| 1 | 100 | 5 | false | 2024-02-05 09:30:26.2080000 | 1 | 2 | 5 | 100 |
You can also put spaces in the column headers so they are easier to read:
Examples:
| Buy | Price | Amount | Is Fill And Kill | Expire Time | Buy Order Id | Sell Order Id | Trade Amount | Trade Price |
| 1 | 100 | 5 | false | 2024-02-05 09:30:26.2080000 | 1 | 2 | 5 | 100 |
The choice to include spaces in column headers is subjective. It is supported to aid readability, but feel free to omit spaces if this does not make the examples table easier to understand.
I have an Excel input file that I need process for the next flow. The current setup is that it imports the Excel into an Azure function to retrieve the data then proceeds to process it. The business logic aspect is mentioned below. The Azure Function will later on be triggered manually or by blob trigger for processing.
Essentially, one of the main requirements is to make the processing aspect of it generic. Generic in the sense that the business logic needs to be capable enough to split the input file into multiple files defined by "custom column(s)". For instance, person "A" wants to group the input file by one column but person "B" may want to group by another column or person "C" may want to group by multiple columns. Also just to add on top of the somewhat complex nature of things, the input files given may not always have the same column names also but for now this can be ignored and can be assumed that the file given has the same column names each time. Any advice?
Requirement: Group the rows based on dynamic input (which tells what to group it by). Currently the dynamic input aspect of it can be done in ANY way (no requirements on this part, can be any format or whatever). The "dynamic input" just tells the business logic what to split the files based on.
Input File:
| ActivityId | RunbookName | Result | ProjectID | Architect | TimeZone
|------------|---------------------|-------------------|-----------|-----------|----------
| 5271D9E9 | Foo | State 2, Status 1 | 111 | Bob | EST
| 5271D9E9 | Foo | State 2, Status 1 | 111 | Ann | EST
| 5271D9E9 | Bar | State 2, Status 3 | 222 | Mike | PST
| 394B044 | Fooey | State 2, Status 1 | 222 | Mike | PST
| 394B044 | Dooey | State 2, Status 1 | 333 | Bob | EST
| D94321B | Dooey | State 2, Status 1 | 333 | Ann | EST
| 9E4371A | Foo | State 2, Status 1 | 333 | Bob | EST
Example: Given the input above, person "A" wants separate files for RunbookName thus the output for person "A" is:
File 1:
| ActivityId | RunbookName | Result | ProjectID | Architect | TimeZone
|------------|---------------------|-------------------|-----------|-----------|----------
| 5271D9E9 | Foo | State 2, Status 1 | 111 | Bob | EST
| 5271D9E9 | Foo | State 2, Status 1 | 111 | Ann | EST
| 9E4371A | Foo | State 2, Status 1 | 333 | Bob | EST
File 2:
| ActivityId | RunbookName | Result | ProjectID | Architect | TimeZone
|------------|---------------------|-------------------|-----------|-----------|----------
| 5271D9E9 | Bar | State 2, Status 3 | 222 | Mike | PST
File 3:
| ActivityId | RunbookName | Result | ProjectID | Architect | TimeZone
|------------|---------------------|-------------------|-----------|-----------|----------
| 394B044 | Dooey | State 2, Status 1 | 333 | Bob | EST
| D94321B | Dooey | State 2, Status 1 | 333 | Ann | EST
File 4:
| ActivityId | RunbookName | Result | ProjectID | Architect | TimeZone
|------------|---------------------|-------------------|-----------|-----------|----------
| 394B044 | Fooey | State 2, Status 1 | 222 | Mike | PST
Example: Given the original input above, person "C" may want separate output files for RunbookName AND Architect thus the output is:
File 1:
| ActivityId | RunbookName | Result | ProjectID | Architect | TimeZone
|------------|---------------------|-------------------|-----------|-----------|----------
| 5271D9E9 | Foo | State 2, Status 1 | 111 | Bob | EST
| 394B044 | Dooey | State 2, Status 1 | 333 | Bob | EST
File 2:
| ActivityId | RunbookName | Result | ProjectID | Architect | TimeZone
|------------|---------------------|-------------------|-----------|-----------|----------
| 5271D9E9 | Bar | State 2, Status 3 | 222 | Mike | PST
| 394B044 | Fooey | State 2, Status 1 | 222 | Mike | PST
File 3:
| ActivityId | RunbookName | Result | ProjectID | Architect | TimeZone
|------------|---------------------|-------------------|-----------|-----------|----------
| 5271D9E9 | Foo | State 2, Status 1 | 111 | Ann | EST
| D94321B | Dooey | State 2, Status 1 | 333 | Ann | EST
Currently I'm having an issue with this piece of code:
//Get all rows that satisfies queryFilter condition
EnumerableRowCollection results = dataTable.AsEnumerable().Where(x => x.Field<string>("RunbookName") == "RunbookName");
I want to achieve something like so, assuming we know the datatype of RunbookName which is provided from dynamic input file the user provides:
//Get all rows that satisfies queryFilter condition
EnumerableRowCollection results = dataTable.AsEnumerable().Where(x => x.Field<dynamic.DataType>(dynamic.ColumnName) == dynamic.ColumnName);
Or even better try to do something like this without having to strongly type it in order to get the value:
//Get all rows that satisfies queryFilter condition
EnumerableRowCollection results = dataTable.AsEnumerable().Where(x => x.Field(dynamic.ColumnName) == dynamic.ColumnName);
Thanks for taking a look at the question.
I'm writing some codes about extract table's structure from SAP using C#, and I've got a question about RFC_READ_TABLE, when I define a table's name and the FIELDS table returned 5 columns, like : FIELDNAME, OFFSET, LENGTH, T and FIELDTEXT, actually I couldn't know what's the decimal places of a numeric field according to these 5 columns, is there any other way to get this? Please be noted that my SAP account is a public one because other peoples are also using it, I'm not supposed to create new function module in SAP.
Below info was what I got from FIELDS table of module RFC_READ_TABLE:
MANDT | 000000 | 000003 | C | Client**: length * 3**
BUKRS | 000003 | 000004 | C | Company Code: **length * 3**
ANLN1 | 000007 | 000012 | C | Main Asset Number: **length * 3**
ANLN2 | 000019 | 000004 | C | Asset Subnumber: **length * 3**
GJAHR | 000023 | 000004 | N | Fiscal Year: **numeric(4,0)**
LNRAN | 000027 | 000005 | N | Sequence Number of Asset Line Items in Fiscal Year: **numeric(5,0)**
AFABE | 000032 | 000002 | N | Real depreciation area: **numeric(2,0)**
ZUJHR | 000034 | 000004 | N | Asset acquisition year (currently not used): **numeric(4,0)**
ZUCOD | 000038 | 000004 | N | Sub-classification of asset acquisitions(currently not used): **numeric(4,0)**
AUFWV | 000042 | 000013 | P | Proportional cumulative revaluation on replacement value: **numeric(13,??=2)**
The datatype of this field is numeric(13,2) according to DB, but how can I get this clue?
thanks in advance!
RFC_READ_TABLE FM returns only summary of field. You can use DDIF_FIELDINFO_GET FM for details.
I'm trying to figure out how to start with this. So each customer should be display bi-weekly starting from the start date. I want the current week to display those that should be display for this week.
Here's my table.
Customers_Id(PK)|First|Last | Address | Phone | Start_Date | Tech_Id (FK) |
----------------+-----+------+--------------+---------+-------------+---------------+
1 | Bob |Smith | 123 Fake St. | 3298492 | 8/4/2010 | 1 |
2 | John|Man | 123 Noe St. | 2930482 | 4/15/2008 | 1 |
3 | Tom |Lee | 123 Polk St. | 9308523 | 6/21/2012 | 2 |
Hopefully this is clear enough.
in mysql, you can do something like:
SELECT * FROM Customers WHERE WEEK(NOW())=WEEK(Start_Date)
This is the answer I have.
SELECT *
FROM Customers
Where DATEDIFF (ww, Start_Da, GETDATE())%2 = 0
How to display data from more than one table to my view using MVP pattern in C# winforms?
Say I have the following tables:
Fruit
Color
Table definition:
+----------+
| Fruit |
+----------+
| Id |
| Name |
| Color_Id |
+----------+
|∞
|
|1
+----------+
| Color |
+----------+
| Id |
| Name |
+----------+
Table contents:
Fruits
+-----+--------+----------+
| Id | Name | Color_Id |
+-----+--------+----------+
| 10 | Apple | 70 |
| 20 | Orange | 80 |
| 30 | Grapes | 90 |
+-----+--------+----------+
Colors
+-----+--------+
| Id | Name |
+-----+--------+
| 70 | Red |
| 80 | Orange |
| 90 | Violet |
+-----+--------+
Then in my solution I have created classes for each tables namely, Fruit and Color class, having their own getters and setters and other details representing the tables in the database.
Then I also created two models for Fruit and Color.
So if I wanted to create a view that will display a record about Color, I would use the model I created for Color to retrieve a collection of colors (e.g. List<Color>).
If I'm using a DataGridView to display that record, I would get something similar like the following:
+-----+--------+
| Id | Name |
+-----+--------+
| 70 | Red |
| 80 | Orange |
| 90 | Violet |
+-----+--------+
For the Fruit records, I could use the same method above but I need to display the color name instead of the color id like the following: (Assuming I'm using a DataGridView or a custom control)
+-----+--------+----------+
| Id | Name | Color |
+-----+--------+----------+
| 10 | Apple | Red |
| 20 | Orange | Orange |
| 30 | Grapes | Violet |
+-----+--------+----------+
I figured I could create another class for it and name it 'FruitColor' then give it properties same as the Fruit class above but instead of having a color id property, I'd replace it with a color name instead... But I'm not really sure if it's the right way of doings thing in MVP. I thought I should ask you guys for any tips on how to do it right...
I'm not using ORM's for my project because I want to understand how do it manually...But I would also appreciate any help related to using ORM's. I also just started learning about MVP 3 weeks ago so I'm really hoping for any help.
When retrieving Fruit, you should query the colours with them using a JOIN in SQL:
RETRIEVE f.*, c.name as color_name
FROM Fruits f
INNER JOIN Colors c
ON f.Color_Id = c.Id
Then, transform the results you get into Fruit as you're probably already doing.
This would, however, require you to expand your Fruit class so it would either have a string property for the color name variable, or just add a property that contains the color as a whole:
public class Fruit
{
public int Id { get; set; }
public string Name { get; set; }
public Color Color { get; set; }
}