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

Re: [agile-usability] How do you unit test web interfaces?

Expand Messages
  • Brian Marick
    ... I have something of an example here, using the Atomic Object s variant of whatever-Martin-Fowler-calls-Model/View/Presenter-these-days:
    Message 1 of 22 , Apr 24, 2007
    • 0 Attachment
      On Apr 24, 2007, at 8:29 AM, Desilets, Alain wrote:

      > Phlip, can you explain more precisely what you mean by "writing a test
      > to the HTML layer or lower". I think I know what you mean, but want to
      > be sure.

      I have something of an example here, using the Atomic Object's
      variant of whatever-Martin-Fowler-calls-Model/View/Presenter-these-days:

      <http://www.testing.com/cgi-bin/blog/2007/01/05#wireframe2>
      <http://www.testing.com/cgi-bin/blog/2007/01/11#wireframe3>
      <http://www.testing.com/cgi-bin/blog/2007/01/18#wireframe4>

      This example assumes a non-HTML app, but I plan to repurpose it to
      HTML to show that's tractable. (Haven't started that yet.) The idea
      of MVP (note: different than MVC) is to make the view very thin and
      put all the view smarts ("when text is entered in this text box, make
      that button visible") into a layer below it. The first link is to a
      movie that explains the Atomic Object style, which uses the Observer
      pattern heavily.

      See also Mike Feather's "Humble Dialog Box":
      <http://www.objectmentor.com/resources/articles/TheHumbleDialogBox.pdf>

      The Atomic Object style uses mocks heavily. I was a little surprised
      to find myself deviating from that. What happened is that I found
      that business-facing tests written as annotated wireframes (and used
      Fit as an execution engine) seemed like just as good a way to test-
      drive the presenter layer, and less work besides.

      I need to get back to that project. So many opportunities to
      experiment, so little time...

      -----
      Brian Marick, independent consultant
      Mostly on agile methods with a testing slant
      www.exampler.com, www.exampler.com/blog
    • Desilets, Alain
      ... Both. In some case, I may even need to test that the javascript embedded in the HTML is working properly. Alain
      Message 2 of 22 , Apr 24, 2007
      • 0 Attachment
        > Alain,
        >
        > What is the focus of your testing? Are you trying to
        > determine if a given query produces the correct output? Or
        > are you trying to test a Use Case through a series of
        > interactions with the system?

        Both.

        In some case, I may even need to test that the javascript embedded in
        the HTML is working properly.

        Alain
      • George Dinwiddie
        ... This all sounds rather far from the concept of unit testing as defined in Test Driven Development. It sounds more like acceptance or customer testing, to
        Message 3 of 22 , Apr 24, 2007
        • 0 Attachment
          Desilets, Alain wrote:
          >> Alain,
          >>
          >> What is the focus of your testing? Are you trying to
          >> determine if a given query produces the correct output? Or
          >> are you trying to test a Use Case through a series of
          >> interactions with the system?
          >
          > Both.
          >
          > In some case, I may even need to test that the javascript embedded in
          > the HTML is working properly.

          This all sounds rather far from the concept of unit testing as defined
          in Test Driven Development. It sounds more like acceptance or customer
          testing, to me. For that, one of the tools to run a real browser (like
          WATIR) is probably the way to go. I'd ask on the agile-testing list. I
          think that you'll get better results, though, if you think through what
          you're trying to accomplish. "Testing everything" at the GUI is not
          often a very productive strategy.

          If you're trying to TDD the gui, then you'll find that a variety of
          tools are needed, as there is no SwissArmyUnit(tm) tool that does
          everything. For TDDing javascript, I've found jsUnit useful.

          - George

          --
          ----------------------------------------------------------------------
          * George Dinwiddie * http://blog.gdinwiddie.com
          Software Development http://www.idiacomputing.com
          Consultant and Coach http://www.agilemaryland.org
          ----------------------------------------------------------------------
        • Desilets, Alain
          ... I agree that testing pathes through several pages is acceptance testing, not unit testing. But I think testing the behaviour of a single web page
          Message 4 of 22 , Apr 25, 2007
          • 0 Attachment
            > > In some case, I may even need to test that the javascript
            > embedded in
            > > the HTML is working properly.
            >
            > This all sounds rather far from the concept of unit testing
            > as defined in Test Driven Development.
            > It sounds more like
            > acceptance or customer testing, to me.


            I agree that testing pathes through several pages is acceptance testing,
            not unit testing.

            But I think testing the behaviour of a single web page (including the
            behaviour of it's embedded JavaScript code) fits the definition of unit
            testing.

            In any case, I have never worried too much about whether I am doing unit
            or acceptance testing. I always do both, usually at the same time, and
            often in the same TestCase files (the later being practice I am trying
            to move away from).

            > For that, one of the
            > tools to run a real browser (like
            > WATIR) is probably the way to go. I'd ask on the
            > agile-testing list. I think that you'll get better results,
            > though, if you think through what you're trying to
            > accomplish. "Testing everything" at the GUI is not often a
            > very productive strategy.

            Thanks for the agile testing hint. I'll post something there (I didn't
            know that list existed).

            I'm not thinking about testing everything at the GUI level. I always
            have more internal tests that check the internals independantly of the
            GUI.

            But the Gui is code too, and it therefore needs to be tested. I'm
            looking for a better way to test it than I have been doing in the past.

            > If you're trying to TDD the gui, then you'll find that a
            > variety of tools are needed, as there is no SwissArmyUnit(tm)
            > tool that does everything. For TDDing javascript, I've found
            > jsUnit useful.

            Yes, I know. Some collegues and I are currently developing a library of
            "manipulators" for wxPython, to make it easier to programmatically
            manipulate widgets in a wxPython application for the purpose of unit
            testing. I'm surprised we had to write that ourselves.


            Alain
          • George Dinwiddie
            ... It fits *some* definitions of unit testing, but not the one I generally use. I generally use the TDD concept of unit testing, rather than the ones
            Message 5 of 22 , Apr 25, 2007
            • 0 Attachment
              Desilets, Alain wrote:
              > But I think testing the behaviour of a single web page (including the
              > behaviour of it's embedded JavaScript code) fits the definition of unit
              > testing.

              It fits *some* definitions of unit testing, but not the one I generally
              use. I generally use the TDD concept of unit testing, rather than the
              ones generally accepted by the testing community. I don't call anything
              "unit testing" if it requires deployment to run.

              The overloading of the term "unit testing" has lead me to prefer
              "programmer testing" instead.

              > Thanks for the agile testing hint. I'll post something there (I didn't
              > know that list existed).
              >
              > I'm not thinking about testing everything at the GUI level. I always
              > have more internal tests that check the internals independantly of the
              > GUI.
              >
              > But the Gui is code too, and it therefore needs to be tested. I'm
              > looking for a better way to test it than I have been doing in the past.

              Yes, and you'll find a good community of testing professionals over
              there who will give you good testing advice. There's also a few of us
              developers there, who tend to look at things from the "TDD as a design
              tool" point of view.

              - George

              --
              ----------------------------------------------------------------------
              * George Dinwiddie * http://blog.gdinwiddie.com
              Software Development http://www.idiacomputing.com
              Consultant and Coach http://www.agilemaryland.org
              ----------------------------------------------------------------------
            • Desilets, Alain
              ... I don t really want to argue about the definition of unit vs acceptance testing. I agree with you that testing which requires deployment sucks, especially
              Message 6 of 22 , Apr 25, 2007
              • 0 Attachment
                > Desilets, Alain wrote:
                > > But I think testing the behaviour of a single web page
                > (including the
                > > behaviour of it's embedded JavaScript code) fits the definition of
                > > unit testing.
                >
                > It fits *some* definitions of unit testing, but not the one I
                > generally use. I generally use the TDD concept of unit
                > testing, rather than the ones generally accepted by the
                > testing community. I don't call anything "unit testing" if
                > it requires deployment to run.

                I don't really want to argue about the definition of unit vs acceptance testing.

                I agree with you that testing which requires deployment sucks, especially if it's manual deployment. I'm looking for tools and techniques that will allow me to do automated testing (whether it be unit or acceptance) of the GUI without requiring too much in the way of deployment. It seems to me that testing the embedded javascript should be possible without full deployment. For example, invoke the script that generates the HTML containing that javascript, then load that HTML into some kind of browser emulator that has a JavaScript interpretor, etc... Dunno if that exists or not.


                ----
                Alain Désilets, MASc
                Agent de recherches/Research Officer
                Institut de technologie de l'information du CNRC /
                NRC Institute for Information Technology

                alain.desilets@...
                Tél/Tel (613) 990-2813
                Facsimile/télécopieur: (613) 952-7151

                Conseil national de recherches Canada, M50, 1200 chemin Montréal,
                Ottawa (Ontario) K1A 0R6
                National Research Council Canada, M50, 1200 Montreal Rd., Ottawa, ON
                K1A 0R6

                Gouvernement du Canada | Government of Canada
              • Desilets, Alain
                ... Thx Brian. I ll have a look. ... Right. When I test non-web GUIs, that s the approach I use. Except that contrarily to Mike, I don t use a MockView. I find
                Message 7 of 22 , Apr 25, 2007
                • 0 Attachment
                  > I have something of an example here, using the Atomic
                  > Object's variant of
                  > whatever-Martin-Fowler-calls-Model/View/Presenter-these-days:
                  >
                  > <http://www.testing.com/cgi-bin/blog/2007/01/05#wireframe2>
                  > <http://www.testing.com/cgi-bin/blog/2007/01/11#wireframe3>
                  > <http://www.testing.com/cgi-bin/blog/2007/01/18#wireframe4>
                  >
                  > This example assumes a non-HTML app, but I plan to repurpose
                  > it to HTML to show that's tractable. (Haven't started that
                  > yet.) The idea of MVP (note: different than MVC) is to make
                  > the view very thin and put all the view smarts ("when text is
                  > entered in this text box, make that button visible") into a
                  > layer below it. The first link is to a movie that explains
                  > the Atomic Object style, which uses the Observer pattern heavily.

                  Thx Brian. I'll have a look.

                  >
                  > See also Mike Feather's "Humble Dialog Box":
                  > <http://www.objectmentor.com/resources/articles/TheHumbleDialo
                  > gBox.pdf>

                  Right. When I test non-web GUIs, that's the approach I use. Except that contrarily to Mike, I don't use a MockView. I find it's just as easy to test using the actual graphical view. And doing it that way catches all sort of silly little bugs in the view. Things like a button not being properly wired to the model method it's supposed to invoke.

                  I haven't figured out how to do this in a web context though, hence my post.


                  ----
                  Alain Désilets, MASc
                  Agent de recherches/Research Officer
                  Institut de technologie de l'information du CNRC /
                  NRC Institute for Information Technology

                  alain.desilets@...
                  Tél/Tel (613) 990-2813
                  Facsimile/télécopieur: (613) 952-7151

                  Conseil national de recherches Canada, M50, 1200 chemin Montréal,
                  Ottawa (Ontario) K1A 0R6
                  National Research Council Canada, M50, 1200 Montreal Rd., Ottawa, ON
                  K1A 0R6

                  Gouvernement du Canada | Government of Canada
                • George Dinwiddie
                  ... If you want to test just the javascript, put it in a .js file and test it with jsUnit. -- ... * George Dinwiddie *
                  Message 8 of 22 , Apr 25, 2007
                  • 0 Attachment
                    Desilets, Alain wrote:
                    > I agree with you that testing which requires deployment sucks,
                    > especially if it's manual deployment. I'm looking for tools and
                    > techniques that will allow me to do automated testing (whether it be
                    > unit or acceptance) of the GUI without requiring too much in the way
                    > of deployment. It seems to me that testing the embedded javascript
                    > should be possible without full deployment. For example, invoke the
                    > script that generates the HTML containing that javascript, then load
                    > that HTML into some kind of browser emulator that has a JavaScript
                    > interpretor, etc... Dunno if that exists or not.

                    If you want to test just the javascript, put it in a .js file and test
                    it with jsUnit.

                    --
                    ----------------------------------------------------------------------
                    * George Dinwiddie * http://blog.gdinwiddie.com
                    Software Development http://www.idiacomputing.com
                    Consultant and Coach http://www.agilemaryland.org
                    ----------------------------------------------------------------------
                  Your message has been successfully submitted and would be delivered to recipients shortly.