Reputation: 443
How can I add an individual test result into a table. I want it in this format:
test_desc | status
--------------------------------
this is test 1 | Pass
--------------------------------
this is test 2 | Fail
Upvotes: 0
Views: 296
Reputation: 116110
You can call ut.run()
as a table function, and return its results from a query. But those results will be a table of varchars. To extract useful information from that, you could parse those results a bit.
The query below works with the standard reporter, but is admittedly a bit rough around the edges and will give incorrect results if your test descriptions contain certain 'trigger' strings (like '[' or 'FAILED'). You could use another reporter, or write your own, to output the results in a format that is more easy to parse.
select
substr(result, 1, instr(result, '[') - 1) as description,
case
when result like '%(FAILED%' then
'FAILED'
when result like '%(DISABLED%' then
'DISABLED'
when result like '%(ERROR%' then
'ERROR'
else
'OK'
end as status
from
( -- Actual test run
select
trim(column_value) as result
from
table(ut.run())
)
where
result like '%[%' /* filter out irrelevant lines */;
Once you've got your results like this, it's of course trivial to insert them into a table using an insert..select statement.
Upvotes: 0
Reputation: 335
Version 2.3.1 included a guide on how to create custom reporter packages. For version 3 I cannot find that in the documentation, but it still uses reporters for the different CI systems. As utPLSQL is licensed under the Apache 2.0 license, you can extend it for your needs and create your own reporter. Check out the existing reporters, in particular the ut_documentation_reporter as a starting point.
Upvotes: 2