tag:blogger.com,1999:blog-1571118467967070047.post1205634392266939971..comments2022-12-02T22:13:38.398-05:00Comments on Loose Couplings: What is testability?Loose Couplingshttp://www.blogger.com/profile/17345615414361178794noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-1571118467967070047.post-34112331256045846532011-02-01T09:56:08.006-05:002011-02-01T09:56:08.006-05:00Good point, agreed. But I also think that if a co...Good point, agreed. But I also think that if a component can be tested in isolation, then it is not necessarily easy to test. The isolation is necessary but is not always sufficient.<br /><br />The main places that I've seen this be a problem (in my own code and others) is in a class with many responsibilities. The collaborators are substitutable, but it's a pain to test because it's doing too much (i.e. not following the Single Responsibility Principle). Refactoring out a class for each responsibility usually does the trick.Loose Couplingshttps://www.blogger.com/profile/17345615414361178794noreply@blogger.comtag:blogger.com,1999:blog-1571118467967070047.post-44343829922101515772011-02-01T02:04:58.334-05:002011-02-01T02:04:58.334-05:00"It could be possible to test a unit in isola..."It could be possible to test a unit in isolation ... But it makes testing difficult because (likely) the class is doing too much [low cohesion]." - this is refuting the other implication - *in isolation* -> *easy* - and I agree of course :) My thesis is that if something cannot be tested in isolation then it is not easy to test.<br /><br />But yeah - extra emphasis - this is a good argument.zbyhttps://www.blogger.com/profile/04636763782334128869noreply@blogger.comtag:blogger.com,1999:blog-1571118467967070047.post-5723781022957664242011-01-31T20:42:54.186-05:002011-01-31T20:42:54.186-05:00I'm not sure I would entirely agree with that....I'm not sure I would entirely agree with that.<br /> <br />It could be possible to test a unit in isolation, but for the test to require, say, a lot of mocks and difficult setup. In other words, the unit doesn't for example instantiate services inline, so it doesn't prevent substitution (and thus does not prevent testing in isolation). But it makes testing difficult because (likely) the class is doing too much [low cohesion].<br /><br />The isolation and the ease are definitely correlated though. But I've found that in discussing testability problems that a little extra emphasis doesn't hurt and is often helpful :)Loose Couplingshttps://www.blogger.com/profile/17345615414361178794noreply@blogger.comtag:blogger.com,1999:blog-1571118467967070047.post-2409705506401116632011-01-31T14:37:43.736-05:002011-01-31T14:37:43.736-05:00Does not *easily* imply *in isolation*?
:)Does not *easily* imply *in isolation*?<br /><br />:)zbyhttps://www.blogger.com/profile/04636763782334128869noreply@blogger.com