diff --git a/source/core/types/ut_executable.tpb b/source/core/types/ut_executable.tpb index d34c70bbe..d41cdd84d 100644 --- a/source/core/types/ut_executable.tpb +++ b/source/core/types/ut_executable.tpb @@ -84,10 +84,13 @@ create or replace type body ut_executable is loop dbms_output.get_line(line => l_line, status => l_status); exit when l_status = 1; - - dbms_lob.writeappend(lob_loc => self.serveroutput, - amount => length(l_line), - buffer => l_line); + + if l_line is not null then + dbms_lob.writeappend(lob_loc => self.serveroutput, + amount => length(l_line), + buffer => l_line); + end if; + dbms_lob.writeappend(lob_loc => self.serveroutput, amount => 1, buffer => chr(10)); diff --git a/tests/RunAll.sql b/tests/RunAll.sql index 607e69fed..76edc1d54 100644 --- a/tests/RunAll.sql +++ b/tests/RunAll.sql @@ -164,6 +164,7 @@ exec ut_coverage.coverage_start_develop(); @@lib/RunTest.sql ut_test/ut_test.BeforeEachProcedureNameNull.sql @@lib/RunTest.sql ut_test/ut_test.TestOutputGathering.sql @@lib/RunTest.sql ut_test/ut_test.TestOutputGatheringForTeamcity.sql +@@lib/RunTest.sql ut_test/ut_test.TestOutputGatheringWhenEmpty.sql @@lib/RunTest.sql ut_test/ut_test.ReportWarningOnRollbackFailed.sql @@lib/RunTest.sql ut_test_suite/ut_test_suite.ErrorsATestWhenAfterTestFails.sql diff --git a/tests/ut_test/ut_test.TestOutputGatheringWhenEmpty.sql b/tests/ut_test/ut_test.TestOutputGatheringWhenEmpty.sql new file mode 100644 index 000000000..9486c4ca6 --- /dev/null +++ b/tests/ut_test/ut_test.TestOutputGatheringWhenEmpty.sql @@ -0,0 +1,55 @@ +create or replace package ut_output_tests +as + --%suite + + --%test + procedure ut_passing_test; + +end; +/ + +create or replace package body ut_output_tests +as + + procedure ut_passing_test + as + begin + --Generate empty output + dbms_output.put_line(''); + ut.expect(1,'Test 1 Should Pass').to_equal(1); + end; + +end; +/ + +declare + l_output_data dbms_output.chararr; + l_num_lines integer := 100000; + l_output clob; +begin + --act + ut.run('ut_output_tests'); + + --assert + dbms_output.get_lines( l_output_data, l_num_lines); + dbms_lob.createtemporary(l_output,true); + for i in 1 .. l_num_lines loop + dbms_lob.append(l_output,l_output_data(i)); + end loop; + + if l_output like '%0 failed, 0 errored, 0 disabled, 0 warning(s)%' then + :test_result := ut_utils.tr_success; + end if; + + if :test_result != ut_utils.tr_success or :test_result is null then + for i in 1 .. l_num_lines loop + dbms_output.put_line(l_output_data(i)); + end loop; + dbms_output.put_line('Failed: Wrong output'); + end if; +end; +/ + +drop package ut_output_tests +/ +