Wednesday, November 11th, 2009

Evidence; that your code will work

Category: Testing

Tobie Langel of Prototype fame has created another unit testing library for JavaScript. Another one I hear you say? Well, if Tobie did it…. it is worth checking out. Time to get some Evidence.

I found out about it over dinner in Berlin at the great JSConf.EU. At the table were 6 people from 6 different countries. Go JavaScript diversity :) I first asked “BDD?” and Tobie spat out “No, I friggin hate BDD, especially for JS” before I had even finished the question.

Tobie gave a talk on Evidence at the show, and explained the focus of the library:

  • Library agnostic (the scripty based one in Prototype was based on Prototype which is weird when you test yourself)
  • Environment agnostic (e.g. not just in the browser)
  • Self contained (no global pollution)
  • Built with async in mind (in JS / client server / anything real, you gotta do async)
  • Easy to automate

  1. Evidence.TestCase.extend('ArrayTest', {
  2.   setUp: function() {
  3.     this.array = ['foo', 'bar', 'baz'];
  4.   },
  6.   testFirst: function() {
  7.     this.assertEqual('foo', _.first(this.array));
  8.     this.assertUndefined(_.first([]));
  9.   },
  11.   testLast: function() {
  12.     this.assertEqual('bar', _.last(this.array),
  13.       'Failed to grab the last element of the array.');
  14.     this.assertUndefined(_.last([]));
  15.   }
  16. });

Posted by Dion Almaer at 6:53 am

2 rating from 81 votes


Comments feed TrackBack URI

I was skeptical of another testing framework at first, but it made more sense after the slides. It’s almost identical to the original Prototype/Scriptactulous testing framework, and by extension JsUnitTest, but removes most of the problems with that tool and adds support for multiple (including non-browser) output formats.

Was there any discussion in the presentation on if and when the upcoming versions of proto/scripty would be moving their tests to this tool?

Comment by smith — November 11, 2009

Sorry, this isn’t so much a problem with this specific project. I’m sick of all the waste caused by this trend in general. You must admit that re-invention is an overarching trend across the JS dev community.

And yes, of course I appreciate next-level devs like Tobie.

Comment by SubtleGradient — November 11, 2009

I see SubtleGradient’s point, but this is hardly restricted to the JS dev community. Java has an incredible number of frameworks for… everything. There are dozens of web frameworks alone, several of which are official standards: Applets, Servlets, JSP/JSTL, JSF and now JavaFX. This doesn’t even include the OSS efforts. It’s the same story for persistence, version/source control, testing, etc.

As a language matures and gains market/mindshare these things happen. If you are opposed to innovation and choice, and all the warts that comes with, an application stack from Microsoft is something to consider. They usually have only 1 or 2 ways of doing things and are those usually supported w/tools and documentation.

Comment by abickford — November 11, 2009

There is much overlap between the terms “research paper” and “term paper”. The phrase “term paper” was originally used to describe a paper (usually a research based paper) that was due at the end of the “term” – either a semester or quarter, depending on which unit of measure a school used. However, the term has fallen out of favor. Common usage has “term paper” and “research paper” as interchangeable, but this is not completely accurate. Not all term papers involve academic research, and not all research papers are term papers. f=””>term paper A term paper is a research paper written by students over an academic term or semester which accounts for a large amount of a grade and makes up much of the course. Term papers are generally intended to describe an event or concept or argue a point. A term paper is A written original work discussing a topic in detail, usually several typed pages in length and is often due at the end of a semester.

Comment by donamier — November 11, 2009

Leave a comment

You must be logged in to post a comment.