Toad World® Forums

Multi-Step tests that include running code


I am in the process of evaluating C/T, and in the process am migrating some hand written tests across to see how C/T handles things.

I have a test that calls a Packaged Procedure which sets a nesting_level variable [i.e. SET_NESTING_LEVEL(n Number) ]. Based on the value of nesting level, other procedures in the package will change there behavior.

Here is the current hand-cranked code of my test…

  -- Set the nesting level to an arbitrary number between 1 and 10 and test
  -- First, get the random number as a whole number
  v_random := ROUND(dbms_random.VALUE * 10,0);
  -- Next set the Nesting level to that number
  -- Now loop (V_RANDOM + 2 ) times and call BEGIN TASK to create a stack
  -- that is larger than our nesting level.
  FOR i IN 1 .. (v_random + 2) LOOP
        Hotsos_Ilo_Task.begin_task('Module'||i, 'Action'||i);
  -- Now get the stack as it is right now and loop through it counting those
  -- records that are considered within the nesting level (V_STACK(i).BNL = FALSE)
  v_stack := Hotsos_Ilo_Task.get_task_stack;
  v_nesting_level := 0;
  FOR i IN 1 .. v_stack.COUNT LOOP
        IF v_stack(i).BNL = FALSE THEN
         v_nesting_level := v_nesting_level + 1;
      END IF;
  package_results := package_results AND (v_nesting_level = v_random);
  print_result('Check if nesting level is working: '|| v_random , package_results);

NOTE: package_results is a boolean that at the beginning of the Unit Test is set to TRUE.

How can I perform this test in C/T. I don’t have any problems getting started and executing the function with a Random Number, but when it comes to executing all of the intermediate code (begin_task) and then testing the outcome of what is in the stack, I’m not sure where to go with that.





Can you tell me exactly what outcome you are trying to test and how that outcome is associated to a given program?

The way Code Tester works today is that you test a specific program and the test takes place by examining specific outcomes. Is the nesting variable to be tested after each program is run?

Or are you essentially wanting to test “meta code” that underlies and is modified by the execution of several programs? If this latter point, then I think what you will probably want to do is build a “driver” program that exercises the different parts and then examines the nesting level.

I will wait to hear back from you and then consider further how best to use Code Tester.