Toad World® Forums

Need ability to programmatically enable/disable test cases


#1

From Marko:

We have suggestion for programmatically enable or disable of test cases. We have temporarily make this by changing package qu_generate. We have one software for all our customers, but some of them are not using everything or it is just working different (customized). This is why we like to make possibility to enable or disable of test case. Is there any option that you upgrade your program with this functionality?


#2

Marko,

First of all, I want to make sure that you know that you can mark unit tests and test cases as INACTIVE right inside the Test Editor.

Now, this is not programmatic.

So let me know if this is what you are looking for:

  • Generate a test definition with all tests active.

  • Before I run the test via the command line, I want to use the PL/SQL API to mark certain tests as inactive in a given schema.

Is this correct? Or do you need this done in a different sort of way? In fact, I might be able to tell you how to do it right now, but I would like to clarify the requirement first.

Thanks, SF


#3

Yes, that is what i am looking for.


#4

Marko,

Today you can specify when you run a test programmatically (outside ofthe UI) that you only want certain unit tests and test cases to run.All others will be ignored. So in this sense, you CAN disable/enable test cases, but to disable, you have to INCLUDE all other test cases and unit tests. That is very awkward.

One thing we will look at adding is an EXCLUSION list. Which things do you NOT want to include.

However, this list will not change the already generated test package. In other words, even if the TC is disabled, the schema running the test must be working with a version of the program being tested that INCLUDES all the programs exercised in the test package.

Hmmm. That sounds confusing. Let’s try it this way: if you have multiple versions of the same package being tested, and schema A has pkg.proc2, but schema B does not have proc2 in pkg, then the test code will not compile.

Make sense?

Thanks, SF


#5

we have temporarly changed your package qu_generate where you generate procedure call for testing procedure.

        pl ('if qct.enabled then ');--added by marko
        IF is_dynamic_in
        THEN
           /*
           Call the program inside a loop that uses the values in the collections
           */
           pl ('populate_collections (l_min_count);');
           pl ('FOR l_index IN 1 .. l_min_count LOOP');
           pl ('   call_the_program (l_index);');
           pl ('END LOOP;');
        ELSE
           pl ('call_the_program;');
        END IF;
        pl ('end if;');--added by marko

I use my function qct.enabled where I programmatically enable or disable specific test case. Why I do that is, I would like that for some specific procedure mypack.myproc to have executed all 7 test cases on one data base, but on the other only 6 out of 7, so one is not executed. Why this one is not executed is because some parameters in my program are not set. This case on that specific data base should never run, and when ran it would raise an exception. So why not set all the parameters. Enabling this parameter will influence in results of my others program and some parameters are exlusing each others.

You can imagine that data base is one of our customer (bank).
Unfortunatly we have a lot of customized programs which in general work the same, but on the other hand they do have some exceptions. They are controled with setting the parameter in some table.

EXCLUSION list
This is not the answer, it is hard coded. How can I enable test case per data base or per some global parameter.

Hmmm. That sounds confusing. Let’s try it this way: if you havemultiple versions of >the same package being tested, and schema A haspkg.proc2, but schema B does >not have proc2 in pkg, then the test codewill not compile.
This is obvious.


#6

Marko,

I think I am slowing down as I get older. I am having some trouble understanding exactly what you want and why my exclusion list is more hard-coded than what you are doing.

So please bear with me and explain a bit more.

You say that you modified the qu_generate package to add this IF statement:

pl ('if qct.enabled then ');-

Two things:

  1. qu_generate is usually wrapped, so you definitely cannot depend on being able to do that.

  2. How do you use the qct.enabled function to give you flexibility to enable or disable specific test cases? What is that function doing? It doesn’t look like it could be flexible enough, since it takes no parameters.

Perhaps you have already sent the example of this code to me or posted; my apologies if that is so. Could you please provide an example here?

Thanks, SF


#7
  1. qu_generate is usually wrapped, so you definitely cannot depend on being able to do that.

We are aware of that. This is the reason why I opened this subject.

  1. How do you use the qct.enabled function to give you flexibility to enable or disable specific test cases?

/in declarations/
P_ID NUMBER := QCT.SET_ID(662); /sets global package parameter, so we do not need any input parameter when we run qct.enabled/
/* we have table qct_def_aktiva with fields: sif_ban (bank id), id (test_case_id 662), status (1=enabled). By default all test cases are enabled. Here we usually disable test cases.*/
when test case is ran pl ('if qct.enabled then ') checks if test case 662 is enabled.

What is that function doing? It doesn’t look like it could be flexible enough, since it takes no parameters.
Just check out records in table qct_def_aktiva if test case is enabled for that data base (bank id). Function have one parameter which is id of test case, QCT.SET_ID(662);


we made package qct (see attachment) for the following reasons:
-to save input parameters of test case in the database.
-enable/disable test case per database
subject in this forum: this threat
-subdescribtion of test case:
subject in this forum: subdescription of test case
-“baseline execution” based on a query, not only for scalars:
subject in this forum: What if we don’t know what our program is going to do in advance?
qct_polni.pb (7.8 KB)