Guest Posted February 18, 2020 Share Posted February 18, 2020 I’ve got a colleague who was brought in as a testing specialist to help improve code quality and reduce bugs. I’ve done a little testing before, but am no means an expert. When they joined I was really excited to learn from them as testing is definitely an area I lack experience. He’s got good coverage and he writes tests for literally everything he does, but it’s something like 95% mocks as opposed to what I would call “black box” testing; testing the input and output. Does that sound reasonable? As I say, I’m not an expert, but his testing strategy doesn’t seem particularly effective and it puts constraints over exactly how code is implemented rather than testing that things behave correctly. Link to comment Share on other sites More sharing options...
ginerjm Posted February 18, 2020 Share Posted February 18, 2020 And are his mocks the kind of tests that a hacker would be doing? Black box testing is something that everyone does just to ensure that the algorithm is correct and that the code is doing what the designer wanted it to be doing. A basic necessity of writing code. What your expert is doing is the hard work of protecting your site/files/dbs/etc. from truly malicious happenings and I understand how it could seem different to you, but it is a true necessity. Link to comment Share on other sites More sharing options...
Psycho Posted February 18, 2020 Share Posted February 18, 2020 The title of your post was with regard to how much mocks should be utilized in Unit Testing. But, in your post you state you feel there is a lack of Black Box testing. Black Box testing is a form of User Acceptance Testing, not a form of Unit Testing, so the title and the content of your post are contradictory. With regard to Unit Testing, there is no "correct" amount that should or should not be comprised of mocks (in my opinion). It should be dependent upon what it is being tested. Now, if your question is really about whether Unit Testing (with or without mocks) replaces the need for Black Box testing, then the answer is No: Unit Testing and User Acceptance Testing are on opposite ends of the spectrum. Micro vs Macro. Link to comment Share on other sites More sharing options...
gizmola Posted February 18, 2020 Share Posted February 18, 2020 With Unit testing, mocks are really the foundation of unit testing with the ultimate goal of improving code coverage. The individual tests themselves have intrinsic input/output, or in some cases a mock is loaded with essential input. I guess the bigger question you want to ask yourself is what is being mocked and why? Link to comment Share on other sites More sharing options...
requinix Posted February 20, 2020 Share Posted February 20, 2020 Sorry folks, turns out OP was a spammer. Looks like the post was copied from r/PHP. Link to comment Share on other sites More sharing options...
Recommended Posts