-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
A business scenario from a firm which transforms data ( experience from FinTech ) #1
Comments
I'll address the part of the question where you have provided a concrete example: * def validator =
"""
function(list) {
var valid = true;
var userValidator = function(user) {
if (typeof user.userId != 'number') valid = false;
if (typeof user.id != 'number') valid = false;
if (typeof user.body != 'string') valid = false;
}
list.forEach(userValidator);
return valid;
}
"""
Given url 'https://jsonplaceholder.typicode.com/posts'
When method get
Then status 200
And assert response.length > 0
And assert validator(response) |
I appreciate the response, but this is not entirely what we intended to test. Observe the following :
{ "userId": int , "id": int , "title": string , "body" : string , "company" : "string" }
if (typeof user.userId != 'number') valid = false;
if (typeof user.id != 'number') valid = false; incredibly bad idea. if user.id was a floating point, that test would pass. Now one can argue that:
This is an implementation bottleneck - but I find it perplexing that no such higher order functions are actually present within the framework.
and now, it is good. Now, in this form, we do not need to change the code ever, even if the schema or anything changes. These are next to impossible to do in languages which were not built for Test Automation. Neither Java, not Python, nor JavaScript cuts it. Groovy is close, but not close enough. Next is the data splicing. From the response I need to arbitrarily project/select and create objects to pass it to the next rest call. That will also be another problem. Again, let me fix the head on aspects here. :-) But my worry is the path you are taking is treaded too many times already - and how to validate predicates should be the main focus - which I do not see much here. With the changes I am suggesting if you try to write libraries in JS or Java, you would see why it won't work. Hope this strikes a cord. |
@nmondal I'll leave it to readers to decide whether your points and concerns are valid. |
Oops correction, #4 is for the iteration syntax. |
Thanks to @nmondal for the awesome feedback. With the latest commit and the introduction of the Given url 'https://jsonplaceholder.typicode.com/posts'
When method get
Then status 200
And assert response.length > 0
And match each response == { userId: '#number', id: '#number', title: '#string', body: '#string' }
|
Here is the file :
The text was updated successfully, but these errors were encountered: