SourceForge has been redesigned. Learn more.
Close

Change request for Listener and Result

2000-02-23
2000-02-28
  • Brian Ewins

    Brian Ewins - 2000-02-23

    Summary: a change to the API to get around problems with count_test_cases, while still providing the same information.

    I'd like both of these to take an 'add_planned' method, with one scalar parameter. Result should pass this on to its listeners, and keep track of the number as described below.

    The point of this is to capture information from T::H style tests. What you expect to happen is that as each new set of tests is run, the T::H test publishes a number like:
    1..10
    which causes the wrapper to call $result->add_planned(10);

    This isnt 'set_planned' because in the case where you're listening to a whole bunch of tests, each will mention its plan just before it runs, and this number should be added to the total number of planned tests.

    This effectively replaces what count_test_cases does with an on-the-fly test count, that we can make work for all kinds of tests. It would be my intention that on T::H testcases, count_test_cases returns 0; and that TestSuites call add_planned for their own test cases only - not a recursive count as c_t_c does, in order to prevent double counting of tests.

    In practice, if you ran tests with this change made, the number of 'planned' tests would start at 0 and jump up as each bunch of tests is started. The number of planned tests (at the end) will be correct, and (if no accidental extra tests are run) the number of planned tests will always be >= the number of actual tests.

    It will still be possible to use the recursive count_all_tests to give an estimate of the total number of tests to be run, but it would only be an estimate.

    Incidentally, the GUI is doing this all wrong :o(. I'm tracking totals myself when of course they are properties of the TestResult.

    The only property (of a test run) which *isnt* currently tracked by TestResult, but is instead tracked by every TestListener, is the benchmark times. Is there not a case for moving the start/stop timings into TestResult::run()?

    Christian - I know you have a comment against my pass-logging code that it extends the API that needs implemented. This is true if the 'croak' methods are left in TestListener, but an alternative implementation is:

    package ...::TestListener;
    use AutoLoader;
    sub AUTOLOAD {
    # define any sub you like on demand.
    *$AUTOLOAD=sub{};
    goto &$AUTOLOAD;
    }

    The implementation of this, and add_pass, only *needs* to go in TestResult, TestSuite, and UnitHarness to make it work; these classes are pretty much 'finals' and arent meant to be subclassed.

     
    • Christian Lemburg

      "Summary: a change to the API to get around problems with count_test_cases, while still
      providing the same information. ... I'd like both of these to take an 'add_planned' method, with one scalar parameter. ... The point of this is to capture information from T::H style tests. ... "

      1) Brian, is this stuff still needed, and if yes, does it change due to your rewriting of the Runners and the Loader?

      2) In my understanding of our informally-evolved style of collaboration here on this project, it would be OK for you to make these changes yourself (in "my" code), if you want - if you keep the testcases up and running. It is not necessary to ask me to do it, IMHO, unless you don't want to make the changes yourself (for whatever reason). How is your view of this?

       
    • Brian Ewins

      Brian Ewins - 2000-02-28

      Its sortof no longer needed. Apart from one (the 'RemoteControl' or 'TestServer') the listeners are now on the other side of a chinese wall from the test cases people will be writing. I still need to do something like this (on my side of the 'wall'), but it doesnt affect your code.

      I've taken the code home on a laptop to work on it, I got to thinking maybe I'd spent too much time on it when I shouldve been working...why no code has been posted, I've been installing ssh etc on the laptop and getting access from home (I've never bothered before as I live close to work, but the company give me access for free...)

      -Baz

       

Log in to post a comment.