Richie
Richie

Reputation: 5199

utplsql how to assert not equal

I'm just getting started with utplsql and am struggling with understanding how to write some simple test cases. There are quite a few good examples of how to test procedures and packages but I'm more after ways to test data.

What I'm trying to achieve in the test below is to assert that the number I get in l_rowcount is not equal to zero. I believe the code below tests that it is equal to zero. It should be pretty simple haha... but I don't know how to do it. The utassert package doesn't have assertnotequal.

Can anyone help me out pls? Much appreciated.

   PROCEDURE ut_oms_tran_head_check_1
   IS 
      l_rowcount1 PLS_INTEGER;
   BEGIN
      -- Run baseline code.
      SELECT COUNT (*)
        INTO l_rowcount1
        FROM sa_tran_head th, sa_store_day sd
       WHERE th.store=sd.store
       AND th.day=sd.day
       AND th.store_day_seq_no=sd.store_day_seq_no
       AND sd.business_date=to_date('09/05/2013','dd/mm/yyyy')
       AND th.cust_order_no is null;

      -- Test results
      utassert.eq (
         'CUST ORDER NO',
         l_rowcount1,
         0
      );
   END;

Upvotes: 4

Views: 1705

Answers (1)

I wish utPLSQL had a .neq method but it doesn't appear to, and modifying the UTASSERT and UTASSERT2 packages is not for the faint-of-heart. What I typically use is something like

UTASSERT.THIS('SOME_VAR (' || SOME_VAR || ') and SOME_OTHER_VAR (' ||
              SOME_OTHER_VAR || ') shouldn''t be equal',
              SOME_VAR <> SOME_OTHER_VAR);

Share and enjoy.

Upvotes: 2

Related Questions