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

Re: YUI Test - How to incorporate into a web application

Expand Messages
  • nicholas.zakas
    Hi Matt, YUI Test does blur the line between unit and functional tests to provide the widest array of options. The general distinction I make is this: Function
    Message 1 of 4 , Apr 29, 2009
    • 0 Attachment
      Hi Matt,

      YUI Test does blur the line between unit and functional tests to provide the widest array of options. The general distinction I make is this:

      Function tests - test the user's experience and must be written after the code.
      Unit tests - test the code and can be written before the code.

      Simulating events can be used in both cases but for very different purposes. Consider the case of YUI Widgets. They use event simulation to test the programmatic responses to certain events. These can't really be classified as functional tests because they are, in a way, testing input/output.

      I tend to think that Selenium is far better a tool for pure functional tests, even though YUI Test can handle them as well.

      Hope this helps,
      Nicholas



      --- In ydn-javascript@yahoogroups.com, "edelmatt" <mattedelman@...> wrote:
      >
      > Thanks Nicholas. It's much appreciated. Follow up question: Do you hvae a rule you use to decide whether to use a YUI unit test versus a (selenium or other) functional test? I've read elsewhere that unit testing should be considered if the test can be written before the method under test is written. This would seem to only include methods for which there is a defined input/output. However, as YUI Test includes the ability to trigger user events (click, etc.) that rule doesn't really hold up.
      >
      > Thanks again,
      > Matt
      >
      > --- In ydn-javascript@yahoogroups.com, "nicholas.zakas" <nzakas@> wrote:
      > >
      > > Hi Matt,
      > >
      > > The way I typically suggest that people go about doing this is through a query string argument that indicates to load YUI Test and the corresponding tests into the page and then runs them within the context of the actual page itself. There shouldn't be any need to use a hidden iframe, just load the necessary files right onto the page and position the console so you can see the results.
      > >
      > > Regards,
      > > Nicholas
      > >
      > >
      > > --- In ydn-javascript@yahoogroups.com, "edelmatt" <mattedelman@> wrote:
      > > >
      > > > Hi All,
      > > >
      > > > I'm just starting to look at YUI Test (and other JS unit testing frameworks). The documentation provided explains the framework functionality quite well. What I'm missing is how one might incorporate YUI Test into an existing web application which uses JavaScript in an unobtrusive/degradable/accessible manner.
      > > >
      > > > In other words, the web application's JavaScript objects and methods do not stand alone, accept input and return output. They manipulate the DOM. Thus, in order to determine whether the JS under test works properly, it must be tested in the context of the DOM.
      > > >
      > > > I imagine that the YUI test framework would exist in a hidden iframe, which could be included in the application during development, but excluded for deployment. Thus the developer could load the given page under test in the dev environment, run the unit tests against the page, and receive the test results via an instance of the Logger printed to an absolute position DIV in the page under test (or the results could be posted to a server for processing).
      > > >
      > > > Can anyone confirm whether this is a valid application of YUI Test? If so, does anyone have any examples or descriptions of using it in this way?
      > > >
      > > > Many thanks!
      > > > Matt Edelman
      > > >
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.