in reply to Re^2: Testing image output
in thread Testing image output

Could I please have some feedback on this test file as testing is not my strongest skill

I pulled a face the instant I saw all those ok functions! From Basic Testing Tutorial by hippo:

While the ok function is useful, the output is a simple pass/fail - it doesn't say how it failed ... Let's use Test::More and its handy cmp_ok function

To convince yourself this is a worthwhile change, try running some failing test cases with your original ok and compare with cmp_ok.

Replies are listed 'Best First'.
Re^4: Testing image output
by Bod (Parson) on Sep 08, 2023 at 23:22 UTC

    Thanks for the bedtime reading...that might improve my abilities with Test::More 👍

    To convince yourself this is a worthwhile change, try running some failing test cases with your original ok and compare with cmp_ok.

    I would take up your suggestion eyepopslikeamosquito but the tests don't fail for me...I would need to upload another dev release to CPAN and wait for some CPAN Testers to generate some results for me. There seem to be precious few testers these days as tests are getting longer and longer before they arrive. I don't want to unnecessarily burden those that are doing this sterling work!

Re^4: Testing image output
by Bod (Parson) on Sep 13, 2023 at 21:55 UTC
    To convince yourself this is a worthwhile change, try running some failing test cases with your original ok and compare with cmp_ok

    I took this advice...
    As expected, I get a more verbose output.

    But, I don't see how it is any more helpful:

    # Testing horizontal image # Failed test 'Correct centre image from horizontal' # at t/02-image.t line 41. # got: '33220702a62b38deb37ef0ce0b4a1a22' # expected: 'c97e63fc792ef75b5ff49c078046321e' # Failed test 'Correct left image from horizontal' # at t/02-image.t line 43. # got: '4a0e69414c9603b0437d22841ef0d300' # expected: '20a5c6517316ebef4c255c12f991dbc7'

      It is (arguably) more helpful because you now have this extra information:

      1. The computed string (the "got") actually looks like a digest of the right length and the right alphabet. This tells you that the code producing that string is performing the right action, just on the wrong source data. Before, the string could have been "" or "aaaaa" or "I can haz cheeseburger" for all you knew.
      2. The computed and expected strings are entirely different, not just say one character out so you have not introduced a typo in the expected string.

      You now have more confidence that the underlying problem is indeed that the source data for the digest is not what it should be, rather than some issue elsewhere in your code or your test script.


      🦛