The RAII (Resource Acquisition Is Initialization) is one of the suggested ways of constructing objects. How does it relate to the unit testing principles that are saying: no complex job done in the constructor? And especially no explicit creation of objects by "new" operator? However creation of some objects requires some more complex steps sometimes, and passing a factory to a constructor makes the API "dirty" in the meaning of decreasing the legibility. What are the general ways of meeting both of the principles at the same time?
I have found the other topic on SO: Stack allocated RAII objects vs DI principle, however it looks like a more general problem and it is not explained well.