|
| 1 | +create or replace package ut_output_tests |
| 2 | +as |
| 3 | + --%suite |
| 4 | + |
| 5 | + --%beforeeach |
| 6 | + procedure beforeeach; |
| 7 | + |
| 8 | + --%aftereach |
| 9 | + procedure aftereach; |
| 10 | + |
| 11 | + --%test |
| 12 | + --%beforetest(beforetest) |
| 13 | + --%aftertest(aftertest) |
| 14 | + procedure ut_passing_test; |
| 15 | + |
| 16 | + procedure beforetest; |
| 17 | + |
| 18 | + procedure aftertest; |
| 19 | + |
| 20 | +end; |
| 21 | +/ |
| 22 | + |
| 23 | +create or replace package body ut_output_tests |
| 24 | +as |
| 25 | + |
| 26 | + procedure beforetest as |
| 27 | + begin |
| 28 | + dbms_output.put_line('<!beforetest!>'); |
| 29 | + end; |
| 30 | + |
| 31 | + procedure aftertest |
| 32 | + as |
| 33 | + begin |
| 34 | + dbms_output.put_line('<!aftertest!>'); |
| 35 | + end; |
| 36 | + |
| 37 | + procedure beforeeach as |
| 38 | + begin |
| 39 | + dbms_output.put_line('<!beforeeach!>'); |
| 40 | + end; |
| 41 | + |
| 42 | + procedure aftereach |
| 43 | + as |
| 44 | + begin |
| 45 | + dbms_output.put_line('<!aftereach!>'); |
| 46 | + end; |
| 47 | + |
| 48 | + procedure ut_passing_test |
| 49 | + as |
| 50 | + begin |
| 51 | + dbms_output.put_line('<!thetest!>'); |
| 52 | + ut.expect(1,'Test 1 Should Pass').to_equal(1); |
| 53 | + end; |
| 54 | + |
| 55 | +end; |
| 56 | +/ |
| 57 | + |
| 58 | +declare |
| 59 | + l_output_data dbms_output.chararr; |
| 60 | + l_num_lines integer := 100000; |
| 61 | + l_output clob; |
| 62 | +begin |
| 63 | + --act |
| 64 | + ut.run('ut_output_tests',ut_teamcity_reporter); |
| 65 | + |
| 66 | + --assert |
| 67 | + dbms_output.get_lines( l_output_data, l_num_lines); |
| 68 | + dbms_lob.createtemporary(l_output,true); |
| 69 | + for i in 1 .. l_num_lines loop |
| 70 | + dbms_lob.append(l_output,l_output_data(i)); |
| 71 | + end loop; |
| 72 | + if l_output like '%##teamcity[testStarted%<!beforeeach!>%<!beforetest!>%<!thetest!>%<!aftertest!>%<!aftereach!>%##teamcity[testFinished%' then |
| 73 | + :test_result := ut_utils.tr_success; |
| 74 | + end if; |
| 75 | + |
| 76 | + if :test_result != ut_utils.tr_success or :test_result is null then |
| 77 | + for i in 1 .. l_num_lines loop |
| 78 | + dbms_output.put_line(l_output_data(i)); |
| 79 | + end loop; |
| 80 | + dbms_output.put_line('Failed: Wrong output'); |
| 81 | + end if; |
| 82 | +end; |
| 83 | +/ |
| 84 | + |
| 85 | +drop package ut_output_tests |
| 86 | +/ |
| 87 | + |
0 commit comments