Unit testing NodeMCU code
Posted: Fri Aug 04, 2017 4:07 am
this is for those of us, interested in more unit testing the code before uploading it to nodemcu.
i've began sketching a simulated implementation of nodemcu api, where callbacks would be working reasonably well and one can control time and data traffic.
one has to clone https://github.com/fikin/nodemcu-lua-mocks and include the files in its own project.
and btw, feel most welcome to help make it better.
here is how one can test alarm:
there is already reasonably well working implementation for wifi, net, gpio, adc and few more.
i've began sketching a simulated implementation of nodemcu api, where callbacks would be working reasonably well and one can control time and data traffic.
one has to clone https://github.com/fikin/nodemcu-lua-mocks and include the files in its own project.
and btw, feel most welcome to help make it better.
here is how one can test alarm:
Code: Select all
require('tmr')
local fired = false
tmr.create(1,tmr.ALARM_SINGLE,function(timerObj)
fired = true
end):start()
Timer.joinAll(2) -- advance time with 2ms
luaunit.assertTrue(fired)
there is already reasonably well working implementation for wifi, net, gpio, adc and few more.