in reply to The chicken and the egg (or how do I pass the module test)

Without regard to the code itself, I'd break the test into parts. First I'd test that I get a response from the object instantiation. Then, I'd test to see if it showed the network device attached. Based on the result of the previous test, I'd test communicating with the device or skip this test.

It sounds, though, like your code doesn't have this kind of granularity for the test suite to test. Perhaps you should consider creating the object either way, as you already suggested. You could then have a status method for it which reports presence or absence of the device. Further future tests could be skipped if the device is not determined to be present.

  • Comment on Re: The chicken and the egg (or how do I pass the module test)

Replies are listed 'Best First'.
Re^2: The chicken and the egg (or how do I pass the module test)
by ruzam (Curate) on Dec 21, 2007 at 21:40 UTC
    Further tests as in the same test script? Or further tests as in additional test scripts that are conditionally skipped?

    (I need to do some reading up on Test::More)
      Unfortunately for this discussion and probably for myself in general, I've not spent enough time with Test::More to make any implementation suggestions. I think the idea of deferring part of the tests and making the ones that require the presence of the hardware to pass conditional is sound, though.