Not able to pass CSV file data to call another feature in background - karate

Not able to call one feature file from another when passing the data via CSV. Same works when i directly give in examples.
The below works
Background:
def rspSes = call read('classpath:helpers/createSessionID.feature') {"customerNo": '#(IP_Customer)'}
Scenario Outline: To validate based on different product combinations
Given path '/v1/sourceAccounts'
And param paymentType = "PERSONAL"
And header cus = IP_Customer
When method get
Then status <status>
Examples:
| IP_Customer | IP_FROM_ACCT | IP_TO_ACCT | AMOUNT | Purpose | Message | status |
| 165942 | 8957 | 1004 | 5.99 | PERSONAL | dkfkdjfkdjkfjdkjfkdjfkjd | 200 |
**However, if I change the above examples to read a CSV file. It is not picking the value from CSV. Tried changing {"customerNo": <IP_Customer>}, still didnt work. **
| read("testData.csv") |

Related

The json key is not being omitted where the cells are empty in examples of Scenario Outline .What change needs to be done?

The following is the scenario Outline i have used . In the first and second row the display_name is empty but still display_name is being sent in my request payload .
Scenario Outline: Negative cases
Given path '/api/check'
And request {name: <name> , description: <description> , display_name: <display_name>}
When method POST
Then status <status>
Examples:
| name | description | display_name |status |
|"" | "sasadss" | | 400 |
|"fddsd" | "" | | 400 |
| "ccs" | "" | "disp " | 400 |
Unfortuately Cucumber Example tables send an empty string. You can use table as an alternative or you can put the whole JSON into a column, many teams do this.
| value |
| { some: 'json' } |
Refer to this example: https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/demo/outline/examples.feature

Printing RTF as part of existing print job

I have an application that uses PrintDocument to print an Invoice, and I want to print some terms and conditions type fine print on 1 portion of the invoice after all of the items, customer info, and such. I am using a richtextbox for this text since I want my user to be able to format the fine print however they wish.
However, I can't print the rtf as I do all my other text, since it just prints the rtf formatting mumbo jumbo instead of the formatted text. I am seeing examples of how to print RTF that involves printing an entire document from a file such as:
PrintDialog1.Document = rtfTextBox.rtf
, but how do I just print a portion of a page with RTF text? Is this even possible? I can't find any examples of doing this anywhere.
Maybe not necessary but here is a visual: The only RTF text is the fine print, everything else on the page will not be.
_____________________________________
| INVOICE page 1 |
| Customer: |
| John Doe |
| 123 Main St |
| |
| Items: |
| 1. Doodad 1 # $5.95 |
| 2. Widget 3 # 1.00 |
| 3 Gizmo 1 # 34.32 |
| |
| Returns must be made in 30 days |
| with original receipt. Must be in |
| original condition. |
| |
| Customer Sig: __________________ |
|____________________________________|
Note: If this isn't possible, is it possible to attach an RTF page to the end of an existing print job? Or can RTF only be printed all on its own as a standalone print job, not mixed with anything else?

Problems with using the bootstrap-datepicker in Fitnesse Tests

In my Fitnesse Tests I want to enter dates through datepicker elements. Sometimes it works. But most of the time a different date, unlike the date that was entered, appears. Here is an example:
| ensure | do | type | on | id=field_id | with | |
| ensure | do | type | on | id=field_id | with | 05.05.1997 |
| check | is | verifyValue | on | id=field_id | [28.05.1997] expected [05.05.1997] |
(To make sure that the field isn't already filled, I pass an empty String first.)
Mostly, the 'day'-statement is different from what was entered. Do you know the reason for this behavior? How can I solve this?
Thanks in advance!
This is related to how you wrote your fixture and not FitNesse, the problem is that it returns a different value and also implies that the previous line didn't work - | ensure | do | type | on | id=field_id | with | 05.05.1997 |

cucumber data table multiple seperate iteration

In the following feature file my requirement is to put one doc_id for every three field. To clarify, I want to check ProductName, manufacturerName and RevisionDate for every doc_id. I came up with following method but I think this is definitely not the preferred one. Can anyone suggest me a better way.
Background:
Given I am in landigpage page after login
Scenario Outline: valid
When I enter "<doc_id>"
And I click the search go button
Then I should get in vault search page
And Search result of "<field>" should match with database
Examples:
| doc_id | field |
| 15 | ProductName |
| 15 | ManufacturerName |
| 15 | RevisionDate |
Examples:
| doc_id | field |
| 16 | ProductName |
| 16 | ManufacturerName |
| 16 | RevisionDate |
You can use single examples table:
Background:
Given I am in landigpage page after login
Scenario Outline: valid
When I enter "<doc_id>"
And I click the search go button
Then I should get in vault search page
And Search result of "<field>" should match with database
Examples:
| doc_id | field |
| 15 | ProductName |
| 15 | ManufacturerName |
| 15 | RevisionDate |
| 16 | ProductName |
| 16 | ManufacturerName |
| 16 | RevisionDate |
I don't see any other way to pass arguments the way you need to. That's what I don't like about Cucumber. It is not that flexible.
Bacckground:
Given I am in landigpage page after login
Scenario Outline: valid
When I enter "<doc_id>"
And I click the search go button
Then I should get in vault search page
And the search results should match the database
Examples:
| doc_id |
| 15 |
| 16 |
and to make this work:
When /^I enter "<\w+>"$/ do | doc_id |
#doc_id = doc_id
...
end
Then "the search results should match the database" do
db_results = db.find(#doc_id) # or something similar
... # compare db_results to actual results
end
This still kind of sucks, because you have doc_id's in your Gherkin, you are relying on a prefilled database and you have a scenario outline; but hey lets save that for other questions :)
Hi i guess you guys are confusing Data Tables and scenario outline.
The solution for above is :
Background:
Given I am in landingpage page after login
Scenario Outline: valid
When I enter "<doc_id>"
And I select to navigate to search page
Then Search result of field should match with database
| ProductName |
| ManufacturerName |
| RevisionDate |
Examples:
| doc_id |
| 15 |
| 16 |
The table can easily be converted to a list or a map that you can use in your step.

SQL - Combining 3 rows per group in a logging scenario

I have reworked our API's logging system to use Azure Table Storage from using SQL storage for cost and performance reasons. I am now migrating our legacy logs to the new system. I am building a SQL query per table that will map the old fields to the new ones, with the intention of exporting to CSV then importing into Azure.
So far, so good. However, one artifact of the previous system is that it logged 3 times per request - call begin, call response and call end - and the new one logs the call as just one log (again, for cost and performance reasons).
Some fields common are common to all three related logs, e.g. the Session which uniquely identifies the call.
Some fields I only want the first log's value, e.g. Date which may be a few seconds different in the second and third log.
Some fields are shared for the three different purposes, e.g. Parameters gives the Input Model for Call Begin, Output Model for Call Response, and HTTP response (e.g. OK) for Call End.
Some fields are unused for two of the purposes, e.g. ExecutionTime is -1 for Call Begin and Call Response, and a value in ms for Call End.
How can I "roll up" the sets of 3 rows into one row per set? I have tried using DISTINCT and GROUP BY, but the fact that some of the information collides is making it very difficult. I apologize that my SQL isn't really good enough to really explain what I'm asking for - so perhaps an example will make it clearer:
Example of what I have:
SQL:
SELECT * FROM [dbo].[Log]
Results:
+---------+---------------------+-------+------------+---------------+---------------+-----------------+--+
| Session | Date | Level | Context | Message | ExecutionTime | Parameters | |
+---------+---------------------+-------+------------+---------------+---------------+-----------------+--+
| 84248B7 | 2014-07-20 19:16:15 | INFO | GET v1/abc | Call Begin | -1 | {"Input":"xx"} | |
| 84248B7 | 2014-07-20 19:16:15 | INFO | GET v1/abc | Call Response | -1 | {"Output":"yy"} | |
| 84248B7 | 2014-07-20 19:16:15 | INFO | GET v1/abc | Call End | 123 | OK | |
| F76BCBB | 2014-07-20 19:16:17 | ERROR | GET v1/def | Call Begin | -1 | {"Input":"ww"} | |
| F76BCBB | 2014-07-20 19:16:18 | ERROR | GET v1/def | Call Response | -1 | {"Output":"vv"} | |
| F76BCBB | 2014-07-20 19:16:18 | ERROR | GET v1/def | Call End | 456 | BadRequest | |
+---------+---------------------+-------+------------+---------------+---------------+-----------------+--+
Example of what I want:
SQL:
[Need to write this query]
Results:
+---------------------+-------+------------+----------+---------------+----------------+-----------------+--------------+
| Date | Level | Context | Message | ExecutionTime | InputModel | OutputModel | HttpResponse |
+---------------------+-------+------------+----------+---------------+----------------+-----------------+--------------+
| 2014-07-20 19:16:15 | INFO | GET v1/abc | Api Call | 123 | {"Input":"xx"} | {"Output":"yy"} | OK |
| 2014-07-20 19:16:17 | ERROR | GET v1/def | Api Call | 456 | {"Input":"ww"} | {"Output":"vv"} | BadRequest |
+---------------------+-------+------------+----------+---------------+----------------+-----------------+--------------+
select L1.Session, L1.Date, L1.Level, L1.Context, 'Api Call' AS Message,
L3.ExecutionTime,
L1.Parameters as InputModel,
L2.Parameters as OutputModel,
L3.Parameters as HttpResponse
from Log L1
inner join Log L2 ON L1.Session = L2.Session
inner join Log L3 ON L1.Session = L3.Session
where L1.Message = 'Call Begin'
and L2.Message = 'Call Response'
and L3.Message = 'Call End'
This would work in your sample.