in reply to Re^12: Cleaning up unused subroutines
in thread Cleaning up unused subroutines

Granted, but you could remove the tests that explicitly test foo(), and see where you stand.

But then you'd have to know that foo() wasn't used--and that is exactly what the OP is trying to discover.

This is not about the utility of tests, or test suites. It's about about solving the OPs problem, and testing your test suite will not do that.

It's also (as an aside to the OPs question), about the limitations of unit test suites and realising that they are only a part of the picture. They must be combined with proper system tests, that is running the real code with realistic data under realistic operating conditions, because coverage tools show you what you've remembered to test, not what you didn't.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^14: Cleaning up unused subroutines
by Somni (Friar) on Oct 26, 2007 at 19:19 UTC
    You wouldn't have to know that specifically foo() wasn't used, you'd simply go through each function, disabling its explicit tests then checking your coverage.

    The test suite is being used here as an automated means of testing with as many inputs as possible. Something not easily done with your original proposed solution. Your solution misses code; utilizing the test suite has a chance of missing less.

      you'd simply go through each function, disabling its explicit tests then checking your coverage.

      FGS! If you comment out the tests of foo() in your test suite, then that is exactly the same as if you had no test suite.

      And, as I showed above, if you have a function call in your code that doesn't have an associated function definition, then Devel::Cover doesn't detect it.

      All you are doing it testing your tests, not your code.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        All right, I'm done. I've tried what I could to explain the merits and mechanics of the idea. If you want to discuss the value in a test suite I'm sure a top-level Meditation would be more appropriate, and I'm sure the rest of PerlMonks would be more than happy to oblige you in some lively discussion.

        Good day.