-
Notifications
You must be signed in to change notification settings - Fork 36
Get back the data you just inserted in its new state in a variable #568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…sing teh following steps:
Does it not the same as doing : Then the users table contains:
"""yaml
- id: 1
firstName: Darth
lastName: Vader
""" ? |
Hello Off course I'm talking about that step: Given that the users table will contain the following data available in users_list: In the exemple I gave the variable If it's not clear please let me know |
The feature has already been implemented here I think : https://github.com/Decathlon/tzatziki/pull/20/files |
They are similar, but not the same |
In this case, I would prefer in the jpa step to do a generic And after you can use this steps to add it in a variable : And that users_list is "{{[_savedEntites]}}" Your test case become : Scenario: we can insert data and retrieve the persisted objects in a variable using table
Given that the users table will contain:
"""yaml
- firstName: Darth
lastName: Vader
"""
And that users_list is "{{[_savedEntites]}}"
Then users_list contains:
"""yaml
- id: 1
firstName: Darth
lastName: Vader
""" It is a little more verbose but more flexible for other use cases. |
This could be a good idea however, users might not remember that specific detail
|
@jak78 What do you think about it ? |
Hey @ibrahimhammani thanks for the suggestion. Could you help me understand what the already implemented feature cannot do? I think the example you provided can be written as follows: Scenario: we can insert data and retrieve the persisted objects in a variable using table
Given that the users table will contain:
"""yaml
- firstName: Darth
lastName: Vader
"""
And users_list is the users table content
Then users_list contains:
"""yaml
- id: 1
firstName: Darth
lastName: Vader
""" |
Thank you for your prompt response. It appears that none of the existing steps can accommodate my specific requirement. Allow me to illustrate with a real-world example: I'm working with a JPA entity that uses a complex ID generator. The generated ID follows a specific pattern, similar to PREFIX_UUID_SUFFIX. When I insert a new record into the database, I need to retrieve it immediately with its generated ID. This is crucial because I then need to use this ID in next steps, such as calling an external API with that generated ID. My objective isn't to test the value of the generated data (ID) , but rather to immediately obtain and utilize the new data, including the ID, generated by Hibernate/JPA. Currently, if I use steps like: Then the users table contains:
"""yaml
...
""" or And users_list is the users table content These will retrieve all data from the table, making it impossible to identify the specific record I just inserted and need to work with. This is especially problematic when test backgrounds insert data into the same table or when I need to insert a large volume of data sequentially. To summarize, my goal is to:
Please let me know if you have any questions. Regards |
Hello all,
Sometimes I have some generated fields in my entity like ID, Creation date ...
So when I insert my data I want to get back my entity with the exact value of the generated field.
I add some steps that allows to do that as follows :
Please check the PR for more details.
Regards