my ColumnFicture test table look like this:
|categoryId|subcategoryId|showResults?|
| 2 | 1 | |
I overwrite in my ficture code (C#) categoryId (2) if subcategory is more than 0. Is that possible overwrite categoryId on fitnesse test site? That evry one can see what happend.
No, from your fixture code you can not change the test in the FitNesse wiki. A test in the wiki is rendered into HTML, passed to a FitServer, parsed into a tree structure, passed to your fixture which can modify the tree, and then rendered into the test result HTML. So your fixture is too far down the pipeline to access the original wiki test source.
Related
How to differentiate test description for parameterized data testing with cucumber? Because for multiple testdata, the description in the scenario outline is showing same when viewing the cucumber report.
Below I am giving an example. On cucumber result, the scenario outline "Verify correct status displaying after filtering" -always visible as same for all the testdata. Is it possible to show three different description for three different testdata? Like "Verify correct verified status displaying after filtering" / "Verify correct pending status displaying after filtering" / "Verify correct rejected status displaying after filtering".
#flights
#flight01
Scenario Outline: TC003_Verify correct status displaying after filtering
Given I am in the xyz application
When I navigate to abcd page
Then Select status "<Status>" from the filter
Then Verify correct "<Status>" should be displayed
Examples:
|Status |
|Verified|
|Pending |
|Rejected|
The way to do that would be to add the parameter to your scenario outline the same way you do for your steps:
eg.
TC003_Verify "<Status>" status displaying after filtering for "<Status>"
This way your scenario results will better convey what you are testing too.
HTH.
The easy way is to just write 3 different scenarios with different titles. There is absolutely no need to use scenario outline when cuking.
When I tested for multiple test data,cucumber report shows the data itself and marked it with pass or fail colors, screenshots below . The description in scenario outline is same but it also copies all the data and it even provides the error. Imo, this eliminates the need to have separate scenario outline with data in it.
and
You have not mention which test runner are you using but the above screen shots are from cucumber 6.9.1 and Junit5 and in junit-platform.properties , you can mention cucumber.plugin = html:target/cucumber.html to have this report generated
I am just wondering if there is a way to make use of karate.config values in Scenario Outline statement. Please have a look at the example below:
Feature: Sample feature
Scenario Outline: Sample scenario for id: <id>
Examples:
| id |
| partnerId |
Here the partnerId is defined in Karate.config file (just say it is '123'). When I run the file I want to see '123' in scenario outline in reports rather than the value holder 'partnerId'
Expected:
You are asking for variables to be able to be substituted into the title. Sorry, that's not supported. You can always print these values so they will show in the HTML report, but yes - not as the title.
Suppose I have test scenario with exact same requirements but one path variable change as follows:
Scenario: Some scenario
Given path /mypath/param1
When method get
Then status 200
I need to run the same test for /mypath/param2, /mypath/param3 as well.
Is there a simpler way to do it without requiring to separate the feature into a separate file and using data driven test?
Yes, use the Scenario Outline which is a standard Cucumber pattern.
Scenario Outline: Some scenario
Given path /mypath/<param>
When method get
Then status 200
Examples:
| param |
| foo |
| bar |
Xmlsample.feature
Feature: test A
Scenario: test apple
* table test_apple_one
| payload_file |
| 'sample/ball.xml' |
* def result = call read('classpath:........./samplereq.feature') test_apple_one
Jsonsample.feature
Feature: test B
Scenario: test Mango
* table test_Mango_one
| payload_file |
| 'sample/cat.`enter code here`json' |
samplereq.feature
Feature: sample
Background:
#Common Config load
* def sampleURL = baseURL+'/sample/test'
* xml payload = read('classpath:.....'+payload_file)
#OAuth Signature generator
* def authorization = "oauth string"
Scenario: Make the sample API call
Given url sampleURL`enter code here`
Given header Authorization = authorization
Given request payload
And header Content-Type = 'application/xml;charset=UTF-8'
And header Host = host
And header Accept = content_type
When method post
Then match header Content-Type contains 'application/xml'
I am using the above feature samplereq.feature for the XML API request and
I Want to keep this feature samplereq.feature as generic and use the same for the Json Api request.can I do the same with JSON(Jsonsample.feature) API request ,please suggest
I read your question multiple times and I am sorry I can't understand what you are trying to do at all. Also I think you have not understood Karate properly. So please listen to my suggestion and take it in the right spirit.
I think you are trying to un-necessarily complicate your test. My sincere suggestion is - please don't try for this extreme re-use. I have observed that when teams attempt to create a super-generic re-usable test script - it just complicates things and becomes hard to maintain.
So please use different feature files for JSON and XML. For each test you can have multiple scenarios. Now, the scenario data can be the same for JSON and XML and you can read a common JSON file. Refer to this example on how you can create XML out of JSON: https://github.com/intuit/karate/blob/master/karate-junit4/src/test/java/com/intuit/karate/junit4/xml/xml.feature
If you still insist on the JSON and XML both in a generic feature, please take a look at this example: https://github.com/intuit/karate/tree/master/karate-demo/src/test/java/demo/loopcall
The above also has an example of calling a JavaScript function. Also please read the docs carefully.
I'm sure this is basic as I'm a new Rails user and want to do Cucumber right. I spent the weekend reading the Pragmatic book and have a small project I want to create and use it. I intentionally set up my first feature as broadly as possible so that it wouldn't be brittle depending too much on how it works on the rails side. I created a new rails app using DanielKehoe's starter on github. I think I got the user figured out. But when I attempt to use Cucumber to creating my first table of Reference Units which would be a table of constants, I expected that cucumber would drive me to create a Reference Units model but I spent all morning trying to get it to do so using the book, Railscasts and stackoverflow to push me to where I'm at now. I went ahead and generated a model for Reference Units, controller with a new action and an empty view. But it now cannot figure out that I have Reference Unit model with a (LoadError). Odd because it's there in the app.
Here's my current feature:
Feature: I want to have Reference Units that I can refer to so they can be used elsewhere. That way
they can be updated in one place. I want to create and edit these Units.
Background:
Given I am logged in as the following user:
| name | "Testy McUserton" |
| password | "please" |
| email | "testy#userton.com" |
Scenario: Adding Reference Units
When I go to the new Reference Units page
And I fill in the following:
| commodity | "corn" |
| language | "en" |
| wholesale unit | "xton" |
| retail unit | "xliter" |
| receipt unit | "dollar" |
Then it should create a new Reference Unit
here is my step definition:
Given /^I am logged in as the following user:$/ do |table|
sign_up valid_user
end
When /^I go to the new Reference Units page$/ do
visit new_reference_unit_path
end
When /^I fill in the following:$/ do |table|
#reference_unit = Reference_unit.create!(table.rows_hash)
end
Then /^it should create a new Reference Unit$/ do
pending # express the regexp above with the code you wish you had
end
new_reference_unit_path is in my feature/support/paths.rb as:
when /the new Reference Units page/
'/reference_units/new'
Running this in 3.1.3 the following is in red:
Scenario: Adding Reference Units # features/user_can_create_units.feature:10
When I go to the new Reference Units page # features/step_definitions/user_create_unit_reference.rb:6
Expected /Users/sam/apps/keriakoo/app/models/reference_unit.rb to define Reference_unit (LoadError)
./app/controllers/reference_units_controller.rb:4:in `new'
./features/step_definitions/user_create_unit_reference.rb:7:in `/^I go to the new Reference Units page$/'
features/user_can_create_units.feature:11:in `When I go to the new Reference Units page'
As I mentioned above. the reference_unit.rb file is in the correct place. Of course, I haven't added any methods or attributes to it expecting cucumber to guide me at the right time. I'm sure it's something simple, but I tried all kinds of combinations of words and capitalization to shake something loose, sam
OK, I think I hit on the clue. Digging around, I used the --backtrace option on cucumber and it pointed me to a dependency with a key word of "const". OK, it doesn't like something in the text. Looking around for info on two-word models, I can tell that my model was correct: ReferenceUnit. But looking at my error output, it was looking for Reference_unit. So for laughs I altered the regex for that step to be "When /^I go to the new Reference units page$" the error went away. So the syntax of the first line is important, and not 'freestylin' as I suspected.