I was finally able to get mxunit and mocking working on my local Windows install but after the sys admin installed it on our Linux server I get the following error only when I use it. It works fine for another app that does not require mocking.
Offending code:
mockLogger = getMockBox().createMock('coldbox.system.logging.Logger');
mockLogger.$("info").$("debug").$("warn").$("error");
model.$property(propertyName="logger", mock=mockLogger);
Error:
/shared/coldbox/system/testing/stubs/9DA00BFE-CBB2-164D-DAB9269585B3E317.cfm (Permission denied)
Is there a something that I should be setting in my test/Application.cfc?
The error is because MXUnit / Mockbox is trying to create the file specified, but CF doesn't have permission to write to that location.
The usual fix for this would be to update the permissions for that stubs directory, so that CF can write and access the files there. (Use chown/chmod, or ask the sys admin to do it.)
The other option is to use a different location which CF does have permission to. You can set this by passing the
generationPath
argument to MockBox when you initialise it, either...... if you're initialising it yourself, or from a unit test...
The path provided needs to be relative - i.e. something cfinclude can use, so it might be worth setting up a mapping.