I have a unit test class Tester
; I want it to access private fields of a Working
class.
class Working {
// ...
private:
-fno-access-control
If you're only using GCC, you can use the compiler option -fno-access-control
while compiling your unit tests. This will cause GCC to skip all access checks, but still keep the class layout the same. I don't know if there is a similar option for other compilers, so this isn't a general solution.