Skip to main content
Solved

Unit test in cp instead_of_trigger


Forum|alt.badge.img

Is it possible to configure a unit test for a control procedure instead_of_trigger?

I have a CP which inputs values when a user changes them in a view. 
The CP does some calculation and then updates values of multiple rows in the database. 

I'm trying to build a unit test for this without succes.
Which unit test type should i use for this case? 
i've tried with update statement and update handler, but without succes.

Best answer by Renée Evertzen

Hola ​@Pieter Jan Bouma , 

The following combination should work to set up a unit test for an instead of trigger:

  • Unit test type: Update statement
  • Type of object: Table
  • Object: the view that the instead of trigger is assigned to

If you need specific data in your view you can assign mock data to the view as well.

Checking whether the outcome of the instead of trigger is correct can then be done through the assertion query.

Hope this helps!

Kind regards, 

Renée

View original
Did this topic help you find an answer to your question?

3 replies

Renée Evertzen
Moderator
Forum|alt.badge.img+4

Hola ​@Pieter Jan Bouma , 

The following combination should work to set up a unit test for an instead of trigger:

  • Unit test type: Update statement
  • Type of object: Table
  • Object: the view that the instead of trigger is assigned to

If you need specific data in your view you can assign mock data to the view as well.

Checking whether the outcome of the instead of trigger is correct can then be done through the assertion query.

Hope this helps!

Kind regards, 

Renée


Forum|alt.badge.img

Thanks for the help! I assigned the table as object instead of the view. 
 


Renée Evertzen
Moderator
Forum|alt.badge.img+4

Awesome! Glad it worked out 😊


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings