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 Hotsos_Ilo_Task.set_nesting_level(v_random); -- 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); END LOOP; -- 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; END LOOP; package_results := package_results AND (v_nesting_level = v_random); print_result('Check if nesting level is working: '|| v_random , package_results); Hotsos_Ilo_Task.end_all_tasks;
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.