Is it possible to set unique data using datatable instead of harcoding,
I need to contruct a crud UI framework where I will be creating a records then verify that records is been fetched , then updating it and verify records is been updated
Given user wants to register for new account with the following details
| firstName | Micheal |
| lastName | Dre |
| email | test#dddd.com |
| phoneNumber | 5555555555 |
So instead of hardcoding , as the records need to be unique for every test run
Planned to user faker java library , not able to figure what is best apporoch to get this , searched varioud forum but not able to contruct same
Thanks in advance
Instead of adding random data using a datatable, you can do so in your step definition. Or create a helper method that creates a random user and call that from your step definition.
The .feature file is intended to describe the behaviour of the system. If you just need a random user to be logged in, the details of that user are not important to describe that behaviour.
So, your step would be:
Given user wants to register for new account
Your step definitions would be something like:
#Given("user wants to register for new account")
public void userRegistersForNewAccount() {
randomUser();
}
and you will have a helper method randomUser() that returns a random user.
The way of designing scenario doesn't looks good. You should check for other ways. However, one of the possible solution for what you are looking for is possible with qaf-cucumber using parameter with rnd prefix. Your step may look like below:
Given user wants to register for new account with the following details
| firstName | Auto${rnd:aaaaa} |
| lastName | ${rnd:aaa} |
| email | Auto-${rnd:aaa}#dddd.com |
| phoneNumber | ${rnd:9999999999} |
Related
My question is much more conceptual than ever. I'd like to describe a good scenario using the Cucumber feature file where I have to have for each row of my Data table a new access token from the Identity Provider.
I.e
Scenario:
Given <Code Authorization>
And <Access Token>
And The client has the following information
| email | FirstName | Phone |
| xpto# | Richard | 343242|
When the client via Post /xpto
Then The API response a Json file
| code | response |
| 200 | xpto |
I'll use a Data Table for this kind of approach. However, I cannot give a static Access Token because it will expire. I should get a new one every time when my test run but It is not my test it self. The Token is just a Data that I have to have to test my scenario.
Is it ok call a REST in an Given Step? If I do this I am mixing up the objective of my scenarios.
Any thougts are welcome not for your mind but by the book. :-)
Kind Regards,
It seems that you need the token in order to set up the scenario. In that case it is fine to have that in a Given step. You can perform REST or other calls in step definitions for that Given step. For ex: It may look something like below. You can change wordings as you like but try to word it in a manner that shows initial state of the application.
Given I have a token for this scenario
And The client has the following information
| email | FirstName | Phone |
|xpto# | Richard | 343242|
...
...
Given steps are meant to establish a given state. It is considered best practice in BDD. You can find this information in official BDD docs here
Also , if you want to read more about the purpose and structure of Given , When and Then , be sure to have a look here
My cucumber Gherkins look like this:
Feature: Story XYZ- Title of Story
"""
Title: Story XYZ- Title of Story
"""
Background:
Given Appointments are being created using "SOAP" API
#scenario1
Scenario Outline: Create an appointment for a New start service order
Given Appointment does not exist for order id "Test_PR_Order123"
When Request for create appointment is received for order "Test_PR_Order123" and following
| FieldName | FieldValue |
| ServiceGroupName | <ServiceGroupName> |
| SerivceGroupID | TestSG123 |
| ServiceType | <ServiceType> |
Then Appointment ID should be created
And Appointment for order "Test_PR_Order123" should have following details
| FieldName | FieldValue |
| ServiceGroupName | <ServiceGroupName> |
| SerivceGroupID | TestSG123 |
| ServiceType | <ServiceType> |
And Appointment history should exist for "Create Appointment"
Examples:
| ServiceType | ServiceGroupName |
| Service1 | ServiceGroup1 |
| Service2 | ServiceGroup2 |
#scenario22
Scenario Outline: Create an appointment for a Change Service order
Given Appointment does not exist for order id "Test_CH_Order123"
When Request for create appointment is received for order "Test_CH_Order123" and following
| FieldName | FieldValue |
| ServiceGroupName | <ServiceGroupName> |
| SerivceGroupID | TestSG123 |
| ServiceType | <ServiceType> |
Then Appointment ID should be created
And Appointment for order "Test_CH_Order123" should have following details
| FieldName | FieldValue |
| ServiceGroupName | <ServiceGroupName> |
| SerivceGroupID | TestSG123 |
| ServiceType | <ServiceType> |
And Appointment history should exist for "Create Appointment"
Examples:
| ServiceType | ServiceGroupName |
| Service1 | ServiceGroup1 |
| Service2 | ServiceGroup2 |
In above feature there is a background which will execute for each example in both Scenario Outline.
Also, in java implementation we have implemented #After and #Before hooks which will also execute for each example.
We are using spring-cucumber for data injection between steps.
Problem occurs when all examples in first scenario outline ends, #After implemented method is invoked 2 times. When 2nd time #After starts at the same time 2nd Scenario Outline examples start executing.
As a result sequential execution of scenarios is disturbed and automation start to fail.
Please suggest if this is a bug in cucumber or we are missing anything.
One of the many things you are missing is keeping scenarios simple. By using a scenario outlines and by embedding so many technical details in your Gherkin you are making things much harder for yourself. In addition you are using before and after hooks to make this work.
Another problem is that your scenarios do not make sense. They are all about making appointments for orders, but your don't at any point create the order.
Finally you have two identical scenarios that you say do different things. The first is for New, the second is for Change. There has to be some difference otherwise you would not need the second scenario.
What I would do is try and extract a single scenario out of this tangle and use that to diagnose any problems. You should be able to end up with something like
Scenario: Create an appointment for an order
Given there is an order
And appointments are made using SOAP
When a new start appointment is made for the order
Then the appointment should be created
And the appointment should have a history
There should be no reason why you can't make this scenario work without any #before or #after. When you have this working then create other scenarios whatever other cases you are trying to examine. Again you should be able to do this without doing any of the following
Using example data to differentiate between scenarios
Using outlines
Using #before and #after
When using Cucumber you want to push the complexity of automation outside of Cucumber. Either pull it up to script before Cucumber starts, or push it down to execute in helper methods that are called in a single step definition. If you keep the complexity in Cucumber and in particular try and link scenarios to each other and use #before and #after to keep state between scenarios you will not have a pleasant time using (misusing) Cucumber.
Its far more likely that your problems are caused by your code than by Cucumbers. Even if Cucumber did have a problem with outlines and hooks, you can fix your problems by just not using them. Outlines are completely unnecessary and hooks are mostly misused.
I am using MonetDB to store and analyze email campaign data. I have one table with about 6 million data. Table has around 30 columns.
When I select some of the data, I realise that data are not correctly inserted/updated.
When I fire "select contactId, email, templateId from statistics.marketing_sent where contactid = '974c47e2'", I expect the following result.
+-----------+---------------------+------------+
| contactid | email | templateid |
+===========+=====================+============+
| 974c47e2 | tom#frerickslaw.com | 34 |
+-----------+---------------------+------------+
But I receive the following result and found email is wrong.
+-----------+-----------------+------------+
| contactid | email | templateid |
+===========+=================+============+
| 974c47e2 | frank#fsfco.com | 34 |
+-----------+-----------------+------------+
I double check my nodejs program that insert and update the data. I do not find any issue.
After that what I do is, I have created new empty table and start inserting/updating on that table. New table has 500k~ data and all ware correct. But I need all those data in main table.
So, I fire "insert into statistics.marketing_sent select * from statistics.marketing_sent_2". And I again found that data are incorrect.
Is there any one who face this kind of issue?
This is weird. Are you absolutely sure that "frank#fsfco.com" is the email associated with the contactid "974c47e2"? Can you please double check the original data that you have inserted into MonetDB (i.e. not selected from "statistics.marketing_sent_2", because how do you know the data in this table are correct?)
Having said that, your problem looks like wrong string pointers have been involved in processing your query. I have seen earlier this year that in some extremely specific cases, the wrong value is used as the OFFSET to point to the string in the string HEAP. That problem was fixed several release ago.
With which MonetDB version were your data inserted? Is this a reproducible problem with the latest release of MonetDB (i.e. Jul2017-SP1)? If the problem persists, can you please submit a bug report (https://www.monetdb.org/bugzilla/) with the table schema, sample data and script/queries to reproduce your problem? Thanks
Jennie
First at all, I'm sorry if I'm re-posting, but I couldn't find anything related.
I'm working on a application that handle very sensitive data. I want to filter this data by user's role.
I've done this (in another job) using Doctrine Filters, but I can't find any information about how to do this using Sequelize (over PostgreSQL).
Eg:
sensitive_information:
| user_id | sensible_value |
+---------+----------------+
| 1 | something |
| 2 | something_else |
I need this:
SELECT *
FROM sensitive_information
WHERE user_id = 1; /** I need this to be added automatically in all
queries to sensitive_information */
So, user 1 never will see information of another user. That's the goal.
Is it possible? I'm open to suggestions.
Thanks in advance.
This can be addressed by using Sequelize scopes.
Since scopes can be functions:
Scopes are defined in the model definition and can be finder objects, or functions returning finder objects
it's easy to define a scope that filters information according to the user that is logged in.
I haven't implemented this exactly scope yet but I have a good idea on how to address it if anyone needs helps with it.
I have a scenario where I want to log in with multiple users, cucumber provides Scenario Outline with Examples to perform this action but this requires the user details to be entered in the feature file. Is there a way to keep the user details in a properties file and call it from there in the Step definition class?
If there is, can someone please provide me with example code say with gmail login scenario? I am using Junit with my cucumber framework,any suggestion with Junit will be highly appreciated.
Thanks
Fola
Below is the way you can call the users from property file, still you need to pass the key in your feature file, but you will be able to get the users from property file.
file.Properties
$password = Test#1
$TestUser_1= TestUser1
Scenario Outline: Verify that Retail
And "User" performs login in SignIn page with "<Test_User>" & "Password"
| Fields | Input_Value |
| input_email | <User_Type> |
| input_password | <password> |
| btn_Sign | |
| img_Tick | |
Examples:
| password | User_Type |
| $password | $TestUser_1 | //User these key in a same way in you property file
Create your step def in a way below
to read DataTable from Ghekin
elements = locatorType.raw();
String userName = elements.get(1).get(1); //here you will get $TestUser_1
String password = elements.get(2).get(1); // Here you will get $password
if (userName.contains("$"))
{
userName = webPropHelper.getTestDataProperty(elements.get(1).get(1));
// here you will get the userName defined in you property file against the key TestUser_1
}
if (password.contains("$")) {
password = webPropHelper.getTestDataProperty(elements.get(2).get(1));
// here you will get the Password defined in you property file against the key $password
}
WebElement emailinputbox = getBDDElement(pageName, userName);
WebElement pwdbox = getBDDElement(pageName, password);
I've been searching sorta the same thing and I found a lot of ridiculous "answers" to this. Overly complicated, when its actually super easy.
My goal was to read from a .txt file
Here is my solution in ruby.
#inject environment properties
Given /^I enter the environment url into a field$/ do
File.open("/PATH/TO/YOUR/env.txt") do |envFile|
envFile.each_line do |environment|
puts environment
keyboard_enter_text environment
end
end
end
Now from Jenkins you can create a parameterized build that writes to a properties file. Viola you're tests are dynamic, enjoy!
Yes.
In a step definition, you can do whatever you want. In your case, just use some regular Java code to read a properties file.
But note that this is not a "best practice" in terms of BDD as your scenario cannot be read anymore by a reader that doesn't have access to the properties file.