Loading ...
Sorry, an error occurred while loading the content.
 

RE: [junit] newbie: Tools to generate junit test (not skeleton)

Expand Messages
  • Ilja Preuss
    ... In fact it seems to me as if tests inferred from the code should always pass by definition. After all they would test that the code is doing what the code
    Message 1 of 8 , Oct 1, 2003
      Chris Dollin wrote:

      > If not, how do you explain to the tool what the test cases
      > are? Inferring them from already-written code is hard (and
      > runs the risk of capturing subtle incorrect behaviour).

      In fact it seems to me as if tests inferred from the code should always
      pass by definition. After all they would test that the code is doing
      what the code is doing...

      Puzzled, Ilja
    • Michael Silverstein
      ... One thing we ve done is implement an object interaction recorder that captures interactions (method and constructor invocations) between an arbitrary
      Message 2 of 8 , Oct 1, 2003
        > Chris Dollin wrote:
        >
        > > If not, how do you explain to the tool what the test cases are?
        > > Inferring them from already-written code is hard (and runs
        > the risk of
        > > capturing subtle incorrect behaviour).
        >

        One thing we've done is implement an object interaction recorder that
        captures interactions (method and constructor invocations) between an
        arbitrary object under test and objects that call it (actors). We can
        then generate unit tests that roughly mimic those interactions as a
        starting point for additional variations.

        The process is:
        1) Start recorder to capture interactions with a specific object
        2) Execute one high-level user story, typically from the GUI
        3) Stop recorder
        4) Generate unit test from recording that mimics interactions between an
        actor and the object under test

        This is a good technique if you've already got a (somewhat) working
        application and would like to rapidly add unit tests for a particular
        class before making changes or additions to it.

        Anyway, you can read more about this technique at
        http://www.silvermark.com/Product/enhancedjunit/.

        I also have an article coming out November in "Software Testing and
        Quality Engineering" magazine (www.stqe.com) that describes a technique
        for using calls to a recording framework within an application to
        automatically generate semantically meaningful tests, at arbitrary
        levels of granularity. I can provide more information if anyone has any
        interest in this sort of thing.

        -----------------------------
        Mike Silverstein
        SilverMark, Inc.
        The Object Testing Company
        www.javatesting.com
        **********************************
        * Makers of "Test Mentor" *
        * and "Enhanced JUnit" Java *
        * component testing tools *
        **********************************

        ---
        Outgoing mail is certified Virus Free.
        Checked by AVG anti-virus system (http://www.grisoft.com).
        Version: 6.0.518 / Virus Database: 316 - Release Date: 9/11/2003
      • jim_gustafson
        Thank you all for your info. Yes. Ideally we should have written the test case _before_ creating the code. Unfortunately, we didnt and now are trying to
        Message 3 of 8 , Oct 1, 2003
          Thank you all for your info.

          Yes. Ideally we should have written the test case _before_ creating
          the code. Unfortunately, we didnt and now are trying to backfill. We
          have several hundred classes that I have to write test cases for.

          I was just hoping for something that would at least give me a start
          (boundary conditions: null, empty string, MIN_VALUE, MAX_VALUE...).
          Then, I would go back through and fix/add in the other tests. But at
          least I would have a first swag at it.

          Thanks again for all your help

          Jim

          --- In junit@yahoogroups.com, "Michael Silverstein"
          <msilverstein@s...> wrote:
          >
          > > Chris Dollin wrote:
          > >
          > > > If not, how do you explain to the tool what the test cases are?
          > > > Inferring them from already-written code is hard (and runs
          > > the risk of
          > > > capturing subtle incorrect behaviour).
          > >
          >
          > One thing we've done is implement an object interaction recorder that
          > captures interactions (method and constructor invocations) between an
          > arbitrary object under test and objects that call it (actors). We can
          > then generate unit tests that roughly mimic those interactions as a
          > starting point for additional variations.
          >
          > The process is:
          > 1) Start recorder to capture interactions with a specific object
          > 2) Execute one high-level user story, typically from the GUI
          > 3) Stop recorder
          > 4) Generate unit test from recording that mimics interactions between an
          > actor and the object under test
          >
          > This is a good technique if you've already got a (somewhat) working
          > application and would like to rapidly add unit tests for a particular
          > class before making changes or additions to it.
          >
          > Anyway, you can read more about this technique at
          > http://www.silvermark.com/Product/enhancedjunit/.
          >
          > I also have an article coming out November in "Software Testing and
          > Quality Engineering" magazine (www.stqe.com) that describes a technique
          > for using calls to a recording framework within an application to
          > automatically generate semantically meaningful tests, at arbitrary
          > levels of granularity. I can provide more information if anyone has any
          > interest in this sort of thing.
          >
          > -----------------------------
          > Mike Silverstein
          > SilverMark, Inc.
          > The Object Testing Company
          > www.javatesting.com
          > **********************************
          > * Makers of "Test Mentor" *
          > * and "Enhanced JUnit" Java *
          > * component testing tools *
          > **********************************
          >
          > ---
          > Outgoing mail is certified Virus Free.
          > Checked by AVG anti-virus system (http://www.grisoft.com).
          > Version: 6.0.518 / Virus Database: 316 - Release Date: 9/11/2003
        • Ilja Preuss
          ... It would probably give you a fast rise in number of tests, yes. Wether it would give you many *usefull* tests I am not so sure... BTW, what is your
          Message 4 of 8 , Oct 1, 2003
            jim_gustafson wrote:
            > I was just hoping for something that would at least give me
            > a start (boundary conditions: null, empty string, MIN_VALUE,
            > MAX_VALUE...). Then, I would go back through and fix/add in the other
            > tests. But at least I would have a first swag at it.

            It would probably give you a fast rise in number of tests, yes. Wether
            it would give you many *usefull* tests I am not so sure...

            BTW, what is your motivation for writing the tests? Are you encountering
            many bugs?

            Did you think about writing acceptance tests?

            Take care, Ilja
          • J. B. Rainsberger
            ... JTest does this, but I m not sure of a free alternative. Best of luck. -- J. B. Rainsberger, Diaspar Software Services http://www.diasparsoftware.com :: +1
            Message 5 of 8 , Oct 1, 2003
              jim_gustafson wrote:

              > Thank you all for your info.
              >
              > Yes. Ideally we should have written the test case _before_ creating
              > the code. Unfortunately, we didnt and now are trying to backfill. We
              > have several hundred classes that I have to write test cases for.
              >
              > I was just hoping for something that would at least give me a start
              > (boundary conditions: null, empty string, MIN_VALUE, MAX_VALUE...).
              > Then, I would go back through and fix/add in the other tests. But at
              > least I would have a first swag at it.

              JTest does this, but I'm not sure of a free alternative.

              Best of luck.
              --
              J. B. Rainsberger,
              Diaspar Software Services
              http://www.diasparsoftware.com :: +1 416 791-8603
              Let's write software that people understand
            Your message has been successfully submitted and would be delivered to recipients shortly.