In current project we are testing api endpoints that are developed using OData protocol. Microsoft implemented framework that implements Odata protocol and it helps experienced developers to expose system data very quickly and efficiently.
We are developing regression test suite for Odata REST api endpoints using following technology stack:
- Ruby
- httpclient gem
- rspec gem
One of important features of regression test suite is robustness on application data changes. In this post I will present evolution of check for orderby Odata filter. We first improperly designed that check making it not robust on application data changes.
Here is first, not data robust version:
it “default orderby” do
response = @api_client.get @customers_list_url, query={“$orderby” => “Name”, “$top” => 2}, ‘Cookie’ => @cookie
json_response = parse_json response.content
expect(json_response[‘value’][0][‘Name’]).to eq ‘Game of Thrones’
expect(json_response[‘value’][1][‘Name’]).to eq ‘Lord of the Rings’
end
and second version, robust on data changes:
it “default orderby” do
response = @api_client.get @customers_list_url, query={“$orderby” => “Name”, “$top” => 2}, ‘Cookie’ => @cookie
json_response = parse_json response.content
expect(json_response[‘value’][0][‘Name’]).to be <= json_response[‘value’][1][‘Name’]
end
In your automated check, always check for what feature actually do, do not check for hardcoded test data values that are result values of the feature.
so this way you depend on what ruby developers mean implementing "<=". you just repeat production code and in case "<=" implementation changed, sorting will be broken and your test will pass
Hi Artem,
thanks for feedback!
Yes, you are right, I am using comparable product, and that is Ruby, in order to check server side (.Net) implementation of orderby feature.
I will receive false positive for combination when both Ruby and server side wrongly implement orderby method.
But I am confident in Ruby implementation of '<='. If that fails, then would not only my test fail, but also a great number of web applications implemented in Ruby.
Regards, KArlo.
Hi Artem
thanks for feedback!
You are right, I am using comparable product for checking server side (.Net) orderby feature, and that is Ruby implementation of '<=' method.
I would receive false positive pass result only if both server side and Ruby orderby method return wrong result.
But I am confident in Ruby implementation of '<='. If that method fails, then would also fail not only my check, but a great number of web applications implemented in Ruby.
Could you please explain in more details your statement:
"…you just repeat production code…" because I do not understand it in this context.
Regards, KArlo.
i thought the application was written in ruby as well =)
Now I understand by knowing context of your reply 🙂
Regards, KArlo.