In a bid of facilitating the increasing penetration of intermittent and random renewable energies, microgrids along with their management algorithms are becoming crucial assets. To prove their effectiveness, these algorithms need to be tested in real environments and/or laboratories, which can be very difficult in many cases, especially at the initial development stages. To solve this issue, this article proposes the use of a laboratory digital twin, i.e., a virtual laboratory with a behaviour that is similar to that of real installations, aimed at facilitating the development, testing and debugging of microgrids management algorithms. The proposed solution is demonstrated to be safe and complete when it comes to test these algorithms.