touchchandra
touchchandra

Reputation: 1556

Encountered Error while executing UTPLSQL test from one schema to another

I connected to 'user1' and executed following, utplsql is installed in 'utp'. I installed utplsql framework from http://utplsql.sourceforge.net/.

BEGIN
     utp.utAssert.eq('test',1,1); 
END; 
/

Error Output

ORA-02291: integrity constraint (UTP.UTR_ERROR_OUTCOME_FK) violated - parent key not found
ORA-06512: at "UTP.UTRERROR", line 149
ORA-06512: at "UTP.UTRERROR", line 324
ORA-06512: at "UTP.UTROUTCOME", line 146
ORA-01400: cannot insert NULL into ("UTP"."UTR_OUTCOME"."RUN_ID")
ORA-06512: at "UTP.UTRESULT2", line 72
ORA-06512: at "UTP.UTASSERT2", line 137
ORA-06512: at "UTP.UTASSERT2", line 541
ORA-06512: at "UTP.UTASSERT", line 118
ORA-06512: at line 2

But the

Upvotes: 2

Views: 1132

Answers (1)

Paul Walker
Paul Walker

Reputation: 2736

Instead of running utAssert.eq directly, you put it inside a test package, then run that with either utPLSQL.test or utPLSQL.run. (I recommend working through the Getting Started section of the utPLSQL documentation).

Define the test package

CREATE OR REPLACE PACKAGE ut_simple IS
    PROCEDURE ut_setup;
    PROCEDURE ut_teardown;
    PROCEDURE ut_simple_test;
END;

CREATE OR REPLACE PACKAGE BODY ut_simple IS
    PROCEDURE ut_setup IS
    BEGIN
        NULL;
    END;

    PROCEDURE ut_teardown IS
    BEGIN
        NULL;
    END;

    PROCEDURE ut_simple_test IS
    BEGIN
         utp.utAssert.eq('test',1,1); 
    END; 
END;

Run the test

exec utp.utplsql.run ('ut_simple');

Upvotes: 3

Related Questions