11
-red
2y

If your “solution” fixes the test case which is failing, it does NOT guarantee that it is the correct fix. You don’t just blindly change whatever piece of code you like to make just the test case pass. You actually also need to analyse the code and ensure that the rest of the intended functionality is still intact.

Comments
  • 3
    Or worse, the issue that gives 2 test cases, the PR that fixes one.
  • 1
    If you follow TDD principle then you stop writing code as soon as the tests are green.

    If a code change fixes a test but the intent is broken then your code either:
    1) is missing another test (which this change would break)

    2) the code is doing more than a test is testing for i. e.
    - method gets a file size
    - method modifies/deletes the file (intent change)
    - method returns file size
    - test checks for expected file size (pass but does not detect the side effects)
  • 1
    @LordPeeve Yes. There is some degree of coverage, sure. But it is not possible to write a test for every case. I mean we cannot substitute human unwillingness to think with tests all the time. We need to work within the realm of reason.
Add Comment