Bug 27190 - Debug REST API tests
Summary: Debug REST API tests
Status: In Discussion
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-10 15:55 UTC by Jonathan Druart
Modified: 2023-07-04 08:41 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 27190: [DO NOT PUSH] example of failure (786 bytes, patch)
2020-12-10 15:56 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27190: Test::Mojo - Always warn the error string on error (1.90 KB, patch)
2020-12-10 15:57 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2020-12-10 15:55:10 UTC
It can be tricky to debug REST API tests. You can get a "received 500 when 200 expected", but you don't have the error.

There is one manual way to do it:

$t->put_ok($url)->status_is(200)->json_is($expected_json)->or( sub { warn $t->tx->res->to_string });

But could we provide a generic way to add a diag in case Test::Mojo fails?
Comment 1 Jonathan Druart 2020-12-10 15:56:50 UTC
Created attachment 114313 [details] [review]
Bug 27190: [DO NOT PUSH] example of failure

Apply patches from 18729 to test this change.
Comment 2 Jonathan Druart 2020-12-10 15:57:16 UTC
Created attachment 114314 [details] [review]
Bug 27190: Test::Mojo - Always warn the error string on error
Comment 3 Jonathan Druart 2020-12-10 15:58:29 UTC
That's pretty ugly, and we will certainly never push it. But at least I will remember next time I need it, hopefully!
Comment 4 Katrin Fischer 2023-07-01 14:44:09 UTC
(In reply to Jonathan Druart from comment #3)
> That's pretty ugly, and we will certainly never push it. But at least I will
> remember next time I need it, hopefully!

Should we close then?
Comment 5 Jonathan Druart 2023-07-04 08:41:34 UTC
(In reply to Katrin Fischer from comment #4)
> (In reply to Jonathan Druart from comment #3)
> > That's pretty ugly, and we will certainly never push it. But at least I will
> > remember next time I need it, hopefully!
> 
> Should we close then?

I don't think so. It's still useful for debugging purpose and we should have something similar in master.