• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Test-Driven JavaScript and cross-platform development

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Please excuse me if this has already been addressed--I haven't had a chance to read through all of the other threads yet... I'm relatively new to both JavaScript and unit testing, but I was under the impression that the big difficulty with web scripting was cross-platform compatibility, and the fact that fixing code for one browser version may well break it for another. How is this addressed when testing JavaScript? Does the testing software need to emulate all of the common browsers and operating systems that are out there?

Thanks!
 
author
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kurt,

Actually testing helps with dealing with multiple browsers and inconsistencies between them. By running a suite of tests across browsers you have a much easier time figuring out which browsers fail which parts of your implementation. As bugs are uncovered by the tests, they can be coded around and solved in the implementation (possibly by extracting certain browser abstractions as separate functions/objects) you will be able to finally pass all tests in all browsers. Now you know that a solution works, and any regressions at a later point is easily caught by the same (and new) tests.

Of course some browser differences are so unexpected that unit testing will allow you to simply stumbling over them all, but once you identify strange behavior in a browser you can write a test which forces the situation to occur and make sure your code copes.

You don't need to emulate all this crazy behavior, because the tests actually run in the browser. Thus, when the tests pass (assuming they have reasonable coverage), your implementation should be cross-browser reliant.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic