Hey all,
so I am very new to testbox, and was able to make some very basic tests work. I am dealing with something a bit harder…was able to figure out how to get the ORM settings working in the runner test, but now i have a services file that is setup with DI and I need to figure out how to mock it…and I know almost nothing about mocking and mockBox.
if you see above I have this…so the getcbchsdmsumapplications is a cfproperty and is using FW/1 di/1 to inject it. So, what i need to do is figure out how to mock it up with the actual data so the next set of code in this method will run…
Is this something simple to do and I just have not understood the docs enough to figure it out yet?
I will look into this.I do wonder why the getcbchsdmsumapplications() which is part of a cfproperty tag which is on another cfc based on the cfcontent extends to that cfc. When a test is run and it calls a method in a cfc, does it run the cfc from top to bottom and notice there are exends which might lead to a cfproperty, or is it just reading the method? if I need to get some DI like DI/1 recognized via a testbox test, am i missing something in a basic test setup, or should testbox just realize it is using DI?
> I do wonder why the getcbchsdmsumapplications() which is part of a cfproperty tag which is on another cfc based on the cfcontent extends to that cfc.
Sorry, that isn’t a complete sentence and I don’t understand. Can you re-phrase it?
> When a test is run and it calls a method in a cfc, does it run the cfc from top to bottom and notice there are exends which might lead to a cfproperty, or is it just reading the method?
Not sure what you’re asking, but I think it really depends on how you’ve set up your testes. Perhaps you can share some code. A typical unit test runs a method in a complete vacuum. There’s no inheritance, DI, magic, or kittens. It just executes the method and if there’s other required methods or objects in a shared scope (like variables or this), then it’s up to you to mock those.
> if I need to get some DI like DI/1 recognized via a testbox test, am i missing something in a basic test setup, or should testbox just realize it is using DI?
Testbox doesn’t really know or care if you’ve decided to perform DI on your model. That’s really up to you in your test setup. Note however, if you are performing DI, then you’re not really running an isolated test, but instead your test is also dependant on whether DI works as well as whether the injected objects work too. There is a type of testing for that called integration. This is built into ColdBox. I’m not sure FW/1 is robust enough to have an integration testing framework. If that’s what you’re after, perhaps you can ask the FW/1 bods.