You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently building up a test suite for our drivers in lua. Right now I have the following problem, that I want to "mock" a global object (class? file?). My test currently requires my main .lua file, and I can succesfully test global variables. Now, that file contains the following codebit:
The C4 is not a library I have access to - so I can't really test it, but thats okay. I would want to make a test like this, in a different file, that has the file from above as required:
it("CreateMessageParameters should call the correct functions", function()
C4= {
ListGetRoomID=function() return"roomID" end,
GetDeviceID=function() return"deviceID" end
}
stub(C4, "ListGetRoomID")
stub(C4, "GetDeviceID")
CreateMessageParameters()
assert.stub(C4.ListGetRoomID).was.called()
assert.stub(C4.GetDeviceID).was.called()
Now, of course, this doesn't work because attempt to index global 'C4' (a nil value). Is there a way to mock/stub this?
The text was updated successfully, but these errors were encountered:
Hello,
I'm currently building up a test suite for our drivers in lua. Right now I have the following problem, that I want to "mock" a global object (class? file?). My test currently requires my main
.lua
file, and I can succesfully test global variables. Now, that file contains the following codebit:The
C4
is not a library I have access to - so I can't really test it, but thats okay. I would want to make a test like this, in a different file, that has the file from above as required:Now, of course, this doesn't work because
attempt to index global 'C4' (a nil value)
. Is there a way to mock/stub this?The text was updated successfully, but these errors were encountered: