Hi,
What do you mean by "When I my order status changes programatically then no code is being executed" ?
What is done to change the order status from created to cancelled on your website ? Do you open a specific URL ?
For example, if the order status is changed during a payment notification, this is usually done with a server to server connection between the payment gateway and your website directly. And thus, if there is a "echo 'test';die;" happening, it will be the server of the payment gateway which will get back a white page with the text "test", not the customer. So you, as a customer won't see anything different whether that code is executed or not.
A better way to check if and when you go into that if is to write something to a file.
That's what we usually do with payment plugins by doing something like that:
hikashop_writeToLog('test');
That hikashop_writeToLog function can be called from anywhere on your website once HikaShop's core is loaded, and it will log in the text in the "payment log file" you can see in the Files section of the HikaShop configuration page.