Toad World® Forums

Test problems with an Type...


#1

Hi everybody,

i defined a type like this:
CREATE OR REPLACE
TYPE ALUCZAK.MY_TYPE AS OBJECT (
text VARCHAR2 (10 BYTE),
nummer NUMBER
);
/

and i defined a function like this:
CREATE OR REPLACE FUNCTION ALUCZAK.Returntypefromanytype (p_type my_type)
RETURN my_type – Return-Wert
IS
v_returnvalue my_type := my_type(null,null);
BEGIN
v_returnvalue := p_type;
RETURN (v_returnvalue);
END Returntypefromanytype;
/

I would like to test this function but if i do so QCTO send an warning like this:
“Code Tester does not yet support native testing of this type.[…]” (see the picture i attached)
i understand, that Code tester doesn´t support my own type, but it must be possible to test my Function, isn´t it?!
How can i test this case?!

Thanks
Andreas Luczak
ScriptV2_SQL4_Test(run mode when tas is opened in TDP).log (178 KB)


#2

I am sorry about the delay in responding…we do not yet support native testing of object type methods - but that is our #1 priority at this very moment and we will soon post a beta with our first pass at this support.

In the meantime, you must build and test wrappers (packaged functions/procs) that call the OT methods after instantiating instances, etc.

You might also check out this:

    Testing attributes of object types 

http://unittest.inside.quest.com/entry.jspa?externalID=2439&categoryID=138

I hope this helps (a little bit anyway).

SF


#3

Hi.

I’m afraid Steven overlooked that you’re not testing your object type directly. So did I the first time I read your post.

Seen that you’ve written a wrapper function you can test it in QCTO (in future versions of QCTO you’ll be able to do it directly as Steven mentioned). However, you need to use special code for initializing input parameter values and you need to base your outcome on an expression.

The following sections describe how you can do this.

Initialization of P_TYPE

Select the line with P_TYPE in Inputs in Test Builder. Click […] and write the following code:

I_P_TYPE := ALUCZAK.MY_TYPE(‘a’, 2);

or whatever values you would like to call your object type constructor with. I_P_TYPE is the name of the variable in the generated test code that holds the value of the input parameter P_TYPE.

Outcome

You need to create an expression to be able to add an outcome as the error message indicates. Such an expression could be the following BOOLEAN expression:

Q##FUNCTION_RETURN_VALUE.text = I_P_TYPE.text AND
Q##FUNCTION_RETURN_VALUE.nummer = I_P_TYPE.nummer

where Q##FUNCTION_RETURN_VALUE is the name of the variable in the generated test code that holds the return value of the function. This expression checks whether the object type instance returned by the function is equal to the object type instance given as input. You can make an arbitrarily complex expression as long as the base data type is supported by QCTO such that you can match that against an expected value.

Hope this helps.

Best regards

Finn Ellebaek Nielsen