◐ Shell
clean mode source ↗

Wrong result for has_suite and is_suite when suite annotation is missing

Describe the bug

The functions ut_runner.has_suites and ut_runner.is_suite return a true, even if the annotation suite is missing.

Provide version info

Information about utPLSQL and Database version,

SQL> declare
  2    l_version varchar2(255);
  3    l_compatibility varchar2(255);
  4  begin
  5    dbms_utility.db_version( l_version, l_compatibility );
  6    dbms_output.put_line( l_version );
  7    dbms_output.put_line( l_compatibility );
  8  end;
  9  /
19.0.0.0.0
19.0.0


PL/SQL procedure successfully completed.

SQL> select substr(ut.version(),1,60) as ut_version from dual;

UT_VERSION                                                  
------------------------------------------------------------
v3.1.8.3148-develop                                         

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
BANNER_FULL
------------------------------------------------------------------------------------------------------------------------------------
BANNER_LEGACY                                                                        CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production           
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production                                                              
Version 19.2.0.0.0                                                                                                                  
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production                    0


SQL> select * from nls_session_parameters;

PARAMETER                      VALUE                                                           
------------------------------ ----------------------------------------------------------------
NLS_LANGUAGE                   AMERICAN                                                        
NLS_TERRITORY                  SWITZERLAND                                                     
NLS_CURRENCY                   SFr.                                                            
NLS_ISO_CURRENCY               SWITZERLAND                                                     
NLS_NUMERIC_CHARACTERS         .'                                                              
NLS_CALENDAR                   GREGORIAN                                                       
NLS_DATE_FORMAT                DD.MM.RR                                                        
NLS_DATE_LANGUAGE              AMERICAN                                                        
NLS_SORT                       BINARY                                                          
NLS_TIME_FORMAT                HH24:MI:SSXFF                                                   
NLS_TIMESTAMP_FORMAT           DD.MM.RR HH24:MI:SSXFF                                          
NLS_TIME_TZ_FORMAT             HH24:MI:SSXFF TZR                                               
NLS_TIMESTAMP_TZ_FORMAT        DD.MM.RR HH24:MI:SSXFF TZR                                      
NLS_DUAL_CURRENCY              SF                                                              
NLS_COMP                       BINARY                                                          
NLS_LENGTH_SEMANTICS           BYTE                                                            
NLS_NCHAR_CONV_EXCP            FALSE                                                           

17 rows selected. 

SQL> select substr(dbms_utility.port_string,1,60) as port_string from dual;

PORT_STRING                                                 
------------------------------------------------------------
x86_64/Linux 2.4.xx  

Information about client software

not relevant.

To Reproduce

  1. connect to a schema without test suites

  2. create the following package

create or replace package test_pkg is
  -- %test
  procedure t1;

  -- %Test
  procedure t2;

  procedure t3;
end test_pkg;
/
  1. run the following query:
with 
   function has_suites return varchar2 is
   begin
      if ut_runner.has_suites(user) then
         return 'true';
      else 
         return 'false';
      end if;
   end;
   function is_suite return varchar2 is
   begin
      if ut_runner.is_suite(user, 'test_pkg') then
         return 'true';
      else 
         return 'false';
      end if;
   end;
   function is_test return varchar2 is
   begin
      if ut_runner.is_test(user, 'test_pkg', 't1') then
         return 'true';
      else 
         return 'false';
      end if;
   end;
select has_suites, is_suite, is_test from dual;
  1. look at the result
HAS_SUITES IS_SUITE   IS_TEST   
---------- ---------- ----------
true       true       false     

the values for has_suites and is_suite are wrong.

  1. run tests
select * from table(ut.run('SCOTT'));
  1. look at the result
Result Sequence                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
---------------
Finished in .000021 seconds
0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)

You see that no tests are executed, this is expected and it confirms, that the result for has_suites and is_suite are wrong.

  1. run alternative annotation cache query
select *
from table(ut_runner.get_suites_info(user, null))
where item_type in ('UT_TEST', 'UT_SUITE');

this query returns no rows, which is correct. An additional confirmation that the result for has_suites and is_suite are wrong.

Expected behavior

has_suites and is_suite should return false, if the annotation suite is not defined.