Closed Ismoh closed 2 years ago
You are not blind / ! LuaUnit only covers unit-testing, not mocking.
There are plenty of library who provide mock capabilities in Lua, I am sure that you will find one which you may want to combine with LuaUnit.
Thanks for your time and reply! I appreciate this a lot.
Okay, so my 'mocking' is working for now. Going to have a look, when it's urgent!
I am using LuaUnit since some months, but now I got to a point where I need to mock a global function provided by a API I do not have access to on github workflow. I already tried to mock those and it's working, but I am not sure, if there is a better way to do so.
I had several looks on the documentation, but it looks like I am blind!
Can someone give me an example, how to mock things?
Thanks in advantage!
Edit: This is, how I try to mock stuff, but feels hacky, somehow? It's working..
https://github.com/Ismoh/NoitaMP/blob/809312fc591a1145d702e050f40372b4cfcd6fcb/.testing/tests/files/scripts/util/file_util_test.lua#L13
https://github.com/Ismoh/NoitaMP/blob/809312fc591a1145d702e050f40372b4cfcd6fcb/.testing/tests/files/scripts/util/file_util_test.lua#L35-L37