Richie
Richie

Reputation: 5199

utplsql test suite looks like it is running but it isn't

I am new to using utplsql so apologies for anything obvious that I might not be understanding. My issue is that I have just created a test suite...

CREATE OR REPLACE PACKAGE BODY ut_test_pkg
IS 
   LP_business_date DATE;
   PROCEDURE ut_setup
   IS
   BEGIN
      select nvl(business_date,trunc(sysdate))
      into LP_business_date
      from my_ut_test_params;   
   END ut_setup;

   PROCEDURE ut_teardown
   IS
   BEGIN
      NULL; 
   END ut_teardown;

   PROCEDURE ut_ttable(I_business_part_date IN DATE)
   IS    
      L_dummy NUMBER:=0;      
   BEGIN
      select count(*) 
      into L_dummy
      from mytable
      where business_part_date=to_date('11/05/2013','dd/mm/yyyy')
      and length(trim(cust_order_no))>0;
      utassert.eq (
         'Successful CUST_ORDER_NO NOT EMPTY',
         L_dummy,
         0
      );  
      dbms_output.put_line('L_dummy ' || L_dummy);
   END ut_ttable;         
END ut_mytest_pkg;
/

Now i define the test with utplsql...

BEGIN
   utsuite.add ('MY TEST SUITE');   
   -- Add two packages for testing
   utpackage.add ('MY TEST SUITE', 'ut_test_pkg');
END;
/

Now I run the test suite...

set serveroutput on
begin
   utplsql.testSuite('MY TEST SUITE',recompile_in=>false);
end;
/

When I query the UT_SUITE table it tells me that the executions count has increases and the last status was SUCCESS however I don't think it is running my test procedure it_table because I have intentionally added conditions for it to fail.

I've also put in some print statements and it is not printing to the buffer.

Has anyone got any ideas what I might be doing wrong?

Oh one last thing.. .UTR error doesn't tell me it's failing either.

thks

Upvotes: 1

Views: 1521

Answers (2)

Elobilo
Elobilo

Reputation: 61

Actually you can run a test without a specific package to run it against (stand alone tests). To do this, write the testing package as normal and then in the test suite definition, add the parameter below in utpackage.add():

 samepackage_in => TRUE

And also, make sure that in this case you give the whole package name. So in the above example it would be:

utPackage.add('my_suite','ut_Manage_cars', samepackage_in => TRUE);

This is actually really used for when the package to be tested also contains its test code. But it can also be used to create a package that just contains test code that can test over more than one package or even integration like functionality. Using this in this way, the package name does not have to start with the ut_ prefix but is advisable.

Upvotes: 1

Teshte
Teshte

Reputation: 632

The problem is that, if you have for example a package Manage_cars, then all the testing code related to that package MUST be in a package ut_Manage_cars. utplsql needs all your testing packages to have the ut_ prefix (if you really really want, you can change this prefix somehow...anyway you still need a prefix for each package that contains testing procedures).

So in this case, when you want to add the package to the test suite you do something like :

utPackage.add('my_suite','Manage_cars');

Notice that when you add packages to the suite, you add the packages that contain the code that NEEDS TO BE TESTED. Not the code that contains the asserts and other utplsql related code(which MUST BE PLACED IN ut_Manage_cars)

Hope this helps..if not reply and i will answer as soon as posible :)

Upvotes: 1

Related Questions