Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

add_results & add_results_for_cases error handling


#1

How does TestRail handle bad tests/cases among otherwise good data for the new api calls? That is, what does response code 400 actually mean?

Are no results added unless there are no errors? Do all results up to the first error get added? Or do all results get added except the errors?

Thanks!


#2

It appears to not add any results if there are any errors. Is that correct? If so, that behavior works for us!


#3

Hello Logan,

Thanks for your posting. Yes, that’s correct. The add_results/add_results_for_cases methods won’t add any results if the validation fails for at least one test result. TestRail uses HTTP 400 for client validation errors and additional error details are usually included in the response (e.g., invalid input format or unknown tests or test cases).

Regards,
Tobias


#4

I sometimes run into issues where a result contains a special character or something that results in a 400 response and breaks the run. I’ve tried my best to filter this sort of thing out of my test results (java / Maven) but something new keeps slipping through.

Do you know of any sure fire way to ‘sanitize’ output via php so that special characters won’t cause an error in TestRail when the add_results api is accessed?


#5

Hi Kent,

Thanks for your posting! Our API bindings fully support non-standard characters and are Unicode/UTF-8 compatible (as is TestRail). You would just need to make sure that the strings you send via the API are encoded as UTF-8 and don’t use a different encoding. Do you use our bindings or a custom script to access the API?

http://docs.gurock.com/testrail-api2/bindings-php

Cheers,
Tobias