S
shilpi.agarwal3373
Guest
Hi, Can't we access DB tables inside @Test annotation? Scnerio is - I am writing test case in ABLUnit for suppose Customer Deletion. So i have 3 situation for deleting the customer- Customer deletion is possible only when customer is valid and no order exist for that customer. 1. Customer does not exist (invalid case) 2. Customer exist but order exist for that customer (invalid case) 3. Customer exist but no order for customer (valid case) What I have done- I write 3 procedures and hardcode the customer number and based on that asserting the results. like- @Test. PROCEDURE Deletecust1: /* Customer can not be deleted, Open order exist for customer */ ASSIGN iCustnum = 11. RUN C:\rishi\test\wrk\customer_maint\procs\deletecustomer.p (INPUT iCustnum, OUTPUT chresult). Assert:equals("Open orders exist for customer.Cannot delete.", chresult). END PROCEDURE. @Test. PROCEDURE Deletecust2: /* Customer doesn't exist */ ASSIGN iCustnum = 99910. RUN C:\rishi\test\wrk\customer_maint\procs\deletecustomer.p (INPUT iCustnum, OUTPUT chresult). Assert:equals("Customer deleted by some other user / Customer does not Exist.Cannot delete.", chresult). END PROCEDURE. @Ignore. @Test. PROCEDURE Deletecust3: /* Valid Test Case */ ASSIGN iCustnum = 3290. RUN C:\rishi\test\wrk\customer_maint\procs\deletecustomer.p (INPUT iCustnum, OUTPUT chresult). Assert:equals("yes", chresult). END PROCEDURE. But I do not want to use hardcoded value of Customer number, just replaced 3 procedures into one procedure by making a new table say "Testing" in the database(autodb) and write ABLUnit test case like this--- @Before. PROCEDURE Before: RUN C:\rishi\test\wrk1\testcasedb.p. ( writing connect statement inside this .p) /*CONNECT C:\rishi\test\data\autodb -S 4500. */ END PROCEDURE. @Test PROCEDURE Deletecust1: FOR EACH Testing WHERE Testing.Proc-Name = "deletecustomer.p" no-lock: ASSIGN iCustnum = integer(testing.input-param). RUN C:\rishi\test\wrk1\customer_maint\procs\deletecustomer.p (INPUT iCustnum, OUTPUT chresult). . Assert:equals(Testing.output-param, chresult). So when I run this test case as ABL UNIT, i am getting following error- "Ambiguous or unknown table Testing" Please suggest.
Continue reading...
Continue reading...