As Justin said, I think this suggestion is fundamentally different from my idea, but as they are now merged, let's continue the discussion.
After few sleeps, it occurred to me that the simplest way to enable testing / production code separation without massive modifications to existing compiling process could be a capability to define another espace as "friend" espace. This per-espace setting could reveal internal (=OS private) actions to the another espace marked as a friend and thus enable referencing these otherwise out-of-the scope actions for testing purposes.
Now that Java support is no more, this simplifies implementation even further. This feature could be achieved using small amounts of .NET reflection trickery or previously suggested InternalsVisibleTo attribute (that has been around since 2002 release of .NET 2.0).
Security-wise, there should be no problems either, (albeit a bit more work during compilation) as friend assemblies can be defined as signed assemblies, too.
Personal opinion, but this topic is really heavily connected with OS small book #2, #5 and #7.
Sampsa and few others above have a point, as the original idea for this discussion has been top voted since 2012. I understand all ideas are not feasible to implement as-is and some are not aligned with Outsystems overall vision at all, but testing is something where Outsystems is reeeaallly under-delivering. This crazy topic of "unit testing" or "testing" has now been a frequent subject for ideas for almost a decade.