1 Reply Latest reply on Jan 19, 2018 9:29 AM by GregV

    Unit Test: All procedures must have values even if they have default values

    Paul Simmons

      This is more of a request that a bug per sae.

       

      When creating a unit test all parameters of a procedure of function must be defined due to the nature of the generated test code.  For my test function the debug code looks as so

       

      DECLARE
       FUNCTION int2bool(i NUMBER)RETURN BOOLEAN AS BEGIN IF (i IS NULL)THEN RETURN NULL;ELSE RETURN (i <> 0);END IF;END int2bool;
      BEGIN
       "XXFND"."XXFND_MV_ADM"."SCHEDULE_MV"(P_NAME=>:1,
        P_START_DATE=>:2,
        P_REPEAT_INTERVAL=>:3,
        P_END_DATE=>:4,
        P_JOB_CLASS=>:5,
        P_ENABLED=>int2bool(:6),
        P_AUTO_DROP=>int2bool(:7),
        P_COMMENTS=>:8);
      END;
      
      
      Bind variables used
      :1              VARCHAR2        IN     TEST_MV                                 
      :2              TIMESTAMP WITH TIME ZONE IN     (null)                                  
      :3              VARCHAR2        IN     freq=minutely;interval=5                
      :4              TIMESTAMP WITH TIME ZONE IN     (null)                                  
      :5              VARCHAR2        IN     DEFAULT_JOB_CLASS                       
      :6              NUMBER          IN     1                                       
      :7              NUMBER          IN     0                                       
      :8              VARCHAR2        IN     MV refresh with fence    
      

       

      my procedure definition is

       

        PROCEDURE schedule_mv(p_name                 IN VARCHAR2
                             ,p_start_date           IN TIMESTAMP WITH TIME ZONE DEFAULT (sysdate+(1/1440))
                             ,p_repeat_interval      IN VARCHAR2                 DEFAULT NULL
                             ,p_end_date             IN TIMESTAMP WITH TIME ZONE DEFAULT NULL
                             ,p_job_class            IN VARCHAR2                 DEFAULT 'DEFAULT_JOB_CLASS'
                             ,p_enabled              IN BOOLEAN                  DEFAULT TRUE
                             ,p_auto_drop            IN BOOLEAN                  DEFAULT FALSE
                             ,p_comments             IN VARCHAR2                 DEFAULT 'MV refresh with fence');
      

       

      However with unit testing I must pass in values for all defaulted values as it will deliver "null" as the value.

       

      It would be nice to be able to remove parameters from the unit test, and let it assume the default values  e.g.

       

      DECLARE
       FUNCTION int2bool(i NUMBER)RETURN BOOLEAN AS BEGIN IF (i IS NULL)THEN RETURN NULL;ELSE RETURN (i <> 0);END IF;END int2bool;
      BEGIN
       "XXFND"."XXFND_MV_ADM"."SCHEDULE_MV"(P_NAME=>:1,
        P_REPEAT_INTERVAL=>:2);
      END;
      
      Bind variables used
      :1              VARCHAR2        IN     TEST_MV                                 
      :2              VARCHAR2        IN     freq=minutely;interval=5               
      

       

      This would allow for accurate variability in the unit test scenario's

       

      Database: OracleXE v11.2.0.2.0

      SQL Developer: 17.4.0.355