%UnitTest - Is there a variable or property that can be checked so the process knows it's executing a unit test?
Yes, that's right, a Cache 2017.1 question. Let's all take a trip in the Wayback Machine.
The company I'm working for is in the process of starting to use the %UnitTest framework, and we are experiencing some errors in the code with some existing logic. Long story short, it looks like the best way to handle the issue would be to recognize we're executing the job as a part of a unit test. Is there any sort of variable or property that can be checked to confirm the process is indeed executing a unit test? A lot of our legacy methods NEW virtually all variables at the top of the method so setting a variable in OnBeforeAllTests() would be futile. Any thoughts?
Thank you kindly for any guidance you're able to provide.
Comments
Looking at https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cl… (thanks DC.AI.!!) if you set a process private global as a flag in OnBeforeAllTests() it will survive any NEW calls in your code, so you should be able to use that to signal that it is part of a unit test.
That's brilliant! It's makes total sense that that could work. Sorry, I've been out of Cache development a little while and forgot all about process private globals. Thank you Ben!
My pleasure! Welcome back to the InterSystems Development Community!