Good morning!
I’m new with utPLSQL and I think that’s a great tool.
This is my test script:
CREATE OR REPLACE TYPE "Test"."TyTest" AS OBJECT
(
"Test" CHAR(4)
);
/
CREATE OR REPLACE TYPE "Test"."TtTest"
AS TABLE OF "Test"."TyTest";
/
CREATE OR REPLACE FUNCTION "Test"."TfTest"
RETURN "Test"."TtTest"
AS "ResultSet" "Test"."TtTest";
BEGIN
SELECT "Test"."TyTest"
(
'Test'
)
BULK COLLECT INTO
"ResultSet"
FROM
"SYS"."DUAL";
RETURN "ResultSet";
END "TfTest";
/
SELECT
"t"."r"."Test" AS "Test"
FROM
(
SELECT
VALUE("o") "r"
FROM
TABLE
(
"Test"."TfTest"()
) "o"
) "t";
/
GRANT EXECUTE ON "Test"."TfTest" TO "UTPLSQL";
/
CREATE OR REPLACE PACKAGE "UTPLSQL".testtftest IS
--%suite(testtftest)
--%suitepath(alltests)
--%test(Test)
PROCEDURE tftest1;
END testtftest;
/
CREATE OR REPLACE PACKAGE BODY "UTPLSQL".testtftest IS
--
-- test tftest case 1: ...
--
PROCEDURE tftest1 IS
"Actual" SYS_REFCURSOR;
"Expected" SYS_REFCURSOR;
BEGIN
-- arrange
-- act
OPEN "Actual" FOR
SELECT
'Test' AS "Test"
FROM
"SYS"."DUAL";
-- tftest.tftest;
OPEN "Expected" FOR
SELECT
"t"."r"."Test" AS "Test"
FROM
(
SELECT
VALUE("o") "r"
FROM
TABLE
(
"Test"."TfTest"()
) "o"
) "t";
-- assert
"UT"."EXPECT"("Actual")."TO_EQUAL"("Expected");
END tftest1;
END testtftest;
/
If I run the test it works fine:
Test O. k.
But if I run code coverage with Schemas under test: UTPLSQL, TEST and include objects: Test.TfTest, UTPLSQL.TESTTFTEST, UTPLSQL.UT, UTPLSQL.UT_EXPECTATION, UTPLSQL.UT_EXPECTATION_COMPOUND like this:
Code Coverage
The result is totally empty:
Code coverage empty
My firts question is What am I doing wrong? Where is my mistake?
Then I run the next text:
CREATE OR REPLACE PACKAGE "UTPLSQL"."TestTfTest" IS
--%suite("TestTfTest")
--%suitepath(alltests)
--%test(Test)
PROCEDURE "TfTest1";
END "TestTfTest";
/
CREATE OR REPLACE PACKAGE BODY "UTPLSQL"."TestTfTest" IS
--
-- test tftest case 1: ...
--
PROCEDURE "TfTest1" IS
"Actual" SYS_REFCURSOR;
"Expected" SYS_REFCURSOR;
BEGIN
-- arrange
-- act
OPEN "Actual" FOR
SELECT
'Test'
FROM
"SYS"."DUAL";
-- tftest.tftest;
OPEN "Expected" FOR
SELECT
"t"."r"."Test" AS "Test"
FROM
(
SELECT
VALUE("o") "r"
FROM
TABLE
(
"Test"."TfTest"()
) "o"
) "t";
-- assert
"UT"."EXPECT"("Actual")."TO_EQUAL"("Expected");
END "TfTest1";
END "TestTfTest";
/
If I run again the test, then I have a wrong result with 0/0 tests (I suppose a double quotes bug) this is the image:
Bad unit test
And if I run a code coverage I obtain the same empty result.
My second question is there a possibility to change templates generated by utPLSQL to have ORACLE reserved words in UPPERCASE, use Schema notation and Double Quotes as name qualifications like SQL standard and use Camell case and not use snake case in objects naming?
I hope to be clear with my example and questions.
I have tried using double quotes in different places but that’s still working wrong even I tested a scalar function but have the same code coverage report empty.
Jamesit0 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.