Is Mocking discouraged? I would like to isolate testing

Just some thoughts …

  • If ModuleB relies on ModuleA it also relies on the correctness of it, i.e., conditional testing might debugging easier – because you know where to look for the failure – but is not enough in its own.

  • If the coupling between ModuleB and ModuleA is not as strong in the first place, i.e., it just happens to use some functions from ModuleA, but could just as well work with a different backend, it should probably restructured to rely on an abstract interface instead. Julia is especially nice in this respect and as soon as an abstract interface has been identified mocking becomes trivial – by just implementing some mock code adhering to the interface.

1 Like