OIL is a domain-specific language under development at Océ for specifying, analysing, and implementing software components. OIL is to have IDE support, transformations to formal modelling languages for requirement verification, and code generation towards general-purpose languages such as C++. Model-based testing is an approach to test whether the behaviour of an implementation conforms to the behaviour described in a formal model. A notable benefit of this approach is the automated test derivation and execution. This master thesis presents a C++ code generator for OIL, implemented in the Spoofax language workbench. The correctness of the code generator is validated by means of model-based testing, implemented in JTorX.