Skip to content

Feed aggregator

RadControls for ASP.NET AJAX Dynamic Data update

Telerik Blogs - 5 hours 4 min ago

This is just another update of RadControls for ASP.NET AJAX control integration with DynamicData for .NET 4.
What's updated:

You can download latest bits from here.

 

Categories: Companies

Survey Shows Continued Developer Shift To Java

WaveMaker Blog - Thu, 07/29/2010 - 22:17

WaveMaker recently conducted a survey of WaveMaker Community members.  The survey focused on how and why developers are migrating from proprietary development platforms to standards-based Java.

Here are some findings:

What Platforms Are Being Modernized?

Almost half of the developers in the survey are migrating from proprietary Microsoft platforms like MS Access (25% of responses) and MS .NET (24% of responses). Other common platforms include Oracle Forms (8%), PowerBuilder (8%) and Lotus Notes (4%).

What Are the Drivers for Migrating from Microsoft Tools to Java?

Over half of all survey respondents are moving from proprietary development platforms to Java to get better support for web development and take advantage of less expensive, open source software. One third of respondents are choosing a new development platform to get better support for cloud development.

  • - Better support for web development 69%
  • - Moving to open source 58%
  • - Moving to Java 42%
  • - Better support for cloud development 33%
Flattening the Learning Curve for Java

According to stackoverflow.com, the average time to learn the Java core is about 10 weeks for an experienced developer – that is just for the language and not for frameworks like Java EE, Spring, Hibernate and Ajax. Survey developers reported that their average time to learn Java using a visual development framework like WaveMaker was 4.4 weeks, less than half the time required to just learn the Java core.

Benefits of Visual Development Platform for Java

A visual development platform for Java such as WaveMaker can dramatically lower development costs. On average, developers reported writing 60% less code with WaveMaker than with a proprietary development platform like Visual Studio. In large part this is because WaveMaker includes a visual IDE that eliminates the need to write code to create basic, form-driven Java applications.

Developers also reported an average 50% improvement in productivity using WaveMaker and a 60% reduction in application maintenance costs. Again, this can be attributed to WaveMaker’s drag and drop IDE. Because WaveMaker generates standard Java applications, developers can switch back and forth between the WYSIWYG WaveMaker studio and a Java coding IDE like Eclipse or NetBeans.

Community Feedback Shows Benefits of Shift to Java

Survey respondents also provided detailed examples of the benefits they have gotten from using WaveMaker to migrate from proprietary platforms like MS Access and MS .NET to standards-based Java. Community member quotes include:

“WaveMaker flat out saved my job! Using WaveMaker, I built an inventory tracking application using 80% less code than I would have needed in MS Access, making me much more valuable to my employer!” – Robert Manshack, New Development, IT, Texas Department of Criminal Justice

“WaveMaker allowed me to quickly build a web-based insurance claims application that was faster and provided more functionality than the original tool – MS Access. Best of all, I did it in only 20% of the time that it took to build the original MS Access application!” – Rob Geib, Partner, MarKur Networks, LLC

“WaveMaker is awesome because it simplifies everything, and for a cheaper price than all of the expensive, hard-to-use programs like Microsoft .NET. I love it!” – Cameron Winget, Cameron Inc.

Original link: http://www.prweb.com/releases/survey-shows-continued/developer-shift-to-java/prweb4322114.htm

Share/Bookmark

Categories: Companies

Ask Satyam — and Be Eligible for a Free Copy of the New YUI 2.8 Book from Packt

Yahoo! User Interface Blog - Thu, 07/29/2010 - 18:03

Satyam (Daniel Barreiro) wrote last week about his experience writing YUI 2.8: Learning the Library, the new YUI 2 volume now available from Packt.

Packt has generously offered a few free electronic copies to YUIBlog readers. Suggest a question or tutorial you’d like to see from Satyam on a YUI 2.8-related topic as a comment on this post, and if Satyam picks your suggested topic for one of his three “Ask Satyam” blog posts Packt will make an electronic copy of Satyam’s book available for you to download.

Satyam will be posting answers to his three favorite questions here on the blog over the next month or so.

Categories: Companies

Forward mapping a model with associations

Telerik Blogs - Thu, 07/29/2010 - 16:55

In this post we will discuss how to add associations in a forward mapping scenario with our Visual Designer. We will start from scratch and build a model with two entities – Category and Product where each Product belongs to at most one Category (a zero-or-one-to-many relationship from the categories to the products).

1. In the solution explorer right-click your project (where you want to add the persistent types) and select OpenAccess -> Add Domain Model. We will create an empty model.

2. The next step is to create a new database which we will name WarehouseDB. Creating a brand new database can be achieved when we select the New Connection option in the next dialog. There we can pick the server name and type our database name. When we click OK we are prompted to add the database to our server.

 

3. After our database has been ...

Categories: Companies

Hookbox

Simon Willison’s Weblog - Thu, 07/29/2010 - 11:48

Hookbox (via). For most web projects, I believe implementing any real-time comet features on a separate stack from the rest of the application makes sense—keep using Rails, Django or PHP for the bulk of the application logic, and offload any WebSocket or Comet requests to a separate stack built on top of something like Node.js, Twisted, EventMachine or Jetty. Hookbox is the best example of that philosophy I’ve yet seen—it’s a Comet server that makes WebHook requests back to your regular application stack to check if a user has permission to publish or subscribe to a given channel. “The key insight is that all application development with hookbox happens either in JavaScript or in the native language of the web application itself”.

Categories: Blogs

canto.js: An Improved HTML5 Canvas API

Simon Willison’s Weblog - Thu, 07/29/2010 - 11:39

canto.js: An Improved HTML5 Canvas API (via). Improved is an understatement: canto adds jQuery-style method chaining, the ability to multiple coordinates to e.g. lineTo at once, relative coordinate methods (regular Canvas does everything in terms of absolute coordinates), the ability to use degrees instead of radians, a rounded corner shortcut, a more convenient .revert() method and a simple parser that can understand SVG path expressions! The only catch: it uses getters and setters so won’t work in IE.

Categories: Blogs

Canto.js: An Improved Canvas API

Ajaxian - Thu, 07/29/2010 - 06:10

Javascript author extraordinaire David Flanagan released Canto.js recently, a lightweight wrapper API for canvas, introduced here and documented at the top of the source code. Example:

PLAIN TEXT JAVASCRIPT: canto("canvas_id").moveTo(100,100).lineTo(200,200,100,200).closePath().stroke();
 

Notice three things:

  • canto() returns an abstraction of the canvas - a "Canto" object.
  • As with jQuery and similar libraries, there's method chaining; each method called on a Canto also returns the Canto.
  • lineTo() has been extended to support multiple lines being drawn in a single call.

Instead of setting the ink properties and then painting it, you can do it all in one step:

PLAIN TEXT JAVASCRIPT: canto("canvas_id").moveTo(100,100).lineTo(200,200,100,200).closePath().stroke({lineWidth: 15, strokeStyle: "red"});
 

And plenty more syntactic sugar - check out the API in the source code comments. Sweet!

Thanks @pkeane.

Categories: Communities

Community Highlights: Adventures in localizing a Cappuccino Application

Cappuccino Blog - Thu, 07/29/2010 - 06:06

Community Highlights: Using Cappuccino to build the MemoryMiner Web Viewer

Back with a second post is John Fox, creator of MemoryMiner, a digital storytelling application for Mac OS X. John writes about the steps he took to localize his Cappuccino application, a web viewer for MemoryMiner.

The post comes complete with sample code, and its worth a read if you’re interested in localizing your own applications.

Categories: Open Source

nodejitsu's node-http-proxy

Simon Willison’s Weblog - Thu, 07/29/2010 - 01:34

nodejitsu’s node-http-proxy (via). Exactly what I’ve been waiting for—a robust HTTP proxy library for Node that makes it trivial to proxy requests to a backend with custom proxy behaviour added in JavaScript. The example app adds an artificial delay to every request to simulate a slow connection, but other exciting potential use cases could include rate limiting, API key restriction, logging, load balancing, lint testing and more besides.

Categories: Blogs

Announcing Ext JS 3.3 Beta – PivotGrids, Calendars and More

Ext JS - Wed, 07/28/2010 - 22:21
We are pleased to announce the availability of Ext JS 3.3 beta 1 for immediate download. This release introduces great new Calendar and PivotGrid components, plus over 160 enhancements and bug fixes.
Categories: Companies

TeamPulse is LIVE!!

Telerik Blogs - Wed, 07/28/2010 - 18:30
The TeamPulse team is excited to announce that our first official release of TeamPulse is now READY for general download.

Here is a quick summary of the features for the Q2 2010 Release:

 

1. Community and Standard Editions

  • Fully functional Community Edition is free with a limitation of 5 users and 1 project
  • Standard Edition is $249 USD per user

 

2. Requirements

  • Story Management
  • Persona Management

 

3. Planning:

  • Project Release Scheduling
  • Iteration Planning
  • Work Decomposition

 

4. Tracking

  • Project Dashboard
  • Story Board
  • Current Iteration Tracking Grid

 

5. Analyze

  • Best Practice Analyzer

 

You can download TeamPulse here: http://www.telerik.com/team-productivity-tools/download.aspx

 

Benefits of TeamPulse: http://www.telerik.com/team-productivity-tools/benefits.aspx

 

Here is a list of all of our produce videos to date:

 

Check out our product page here: http://www.telerik.com/team-productivity-tools.aspx

 

Don’t ...

Categories: Companies

The new Telerik OpenAccess Schema Update wizard

Telerik Blogs - Wed, 07/28/2010 - 18:00

One of the new features of Telerik OpenAccess ORM Visual designer is the forward mapping wizard that can be used to update the database schema from the model. Yes it is true! With just few clicks you are able to generate and execute either a schema definition or schema update script that will alter you database schema.

First you will need to open our Schema Update Wizard. You can do this by either right clicking in the schema explorer or in the model explorer: the command is named Update Database from Model… This will open the following page:

schemaUpdateWizardFirstPage

On the first page you can select from several schema update strategies (you can do so from the first panel):

  1. Generate schema definition script – Generates a complete schema definition script. This option will not take in consideration the current schema.
  2. Generate schema migration script – Generates a migration script. The migration ...
Categories: Companies

Explained: RadGridView for WinForms virtualization and its implications. The case with CellElement and RowElement

Telerik Blogs - Wed, 07/28/2010 - 17:30

As the Logical vs. Visual Grid Structure help article states, RadGridView for WinForms uses virtualization for its cells/rows and as of Q2 2010 there is column virtualization as well. What is virtualization? To put it simply, when you bind RadGridView to a DataTable with 1000 rows, you get 1000 data row objects created in RadGridView (of type GridViewDataRowInfo). However, not all data row objects can be visible at the same time in the RadGridView estate in your application. This is why only the visual rows that can be shown in the estate get created (these visual rows are of type GridDataRowElement), or about 20-30 rows for an average application with medium sized RadGridView. These visual rows are reused during scrolling, filtering and other operations with the grid, meaning dramatically improved performance and memory footprint as we create only a small number of visual items, rather than all of them. This ...

Categories: Companies

JustMock. The tale continues... (Part 3)

Telerik Blogs - Wed, 07/28/2010 - 17:00

Last time we saw how we can inject code at the beginning of generic methods. Today I will show you how to inject code in properties. I will cover the syntax for static classes as well.

So, let's start with a demo program that I will explain line-by-line.

using System; using Telerik.CodeWeaver.Hook;   namespace ConsoleApplication4 {     public sealed class TargetClass1     {         public TargetClass1(string text)         {             Text = InitText = text;         }           public string InitText { get; private set; }           public string Text { get; private set; }           public int Integer         {             set { throw new NotImplementedException(); }         }     }       public static class TargetStaticClass     {         public static void PrintText(string text)         {             Console.WriteLine(text);         }     }       class Program     {         ...
Categories: Companies

Firefox 4 Beta 2 now available for download

Mozilla Developer News - Tue, 07/27/2010 - 22:37

The Mozilla community is proud to announce that Firefox 4 Beta 2 is now available for download on Mac, Windows or Linux.

Firefox 4 Beta 2 includes several major features and improvements – by testing them early we’ll be able to respond to your feedback for future versions of Firefox. The included Feedback Add-On that helps you let us know what you think about the new features and technologies in the beta. You can read more about this release on the Mozilla Blog, or at any of the following links:

We want to thank the Mozilla community of nightly testers for the amazing feedback that helped shaped Firefox 4 Beta 2. We appreciate your assistance in testing this preview of the next version of Firefox!

Categories: Open Source

YUI 3.2.0 preview release 1 – touch events support, transitions and browser-specific loading

Ajaxian - Tue, 07/27/2010 - 20:34

Over at the the YUI blog the team just announced the preview release of YUI 3.2.0. YUI3 now has some interesting new features that the team wants you to try and tell them if they work out for you. The changes to the already very powerful library are quite ambitious:

So check out what is on offer and give the YUI team feedback on what would be nice to have and what is broken. In their own words:

The goal of a preview release is to make it as easy as possible for all of us in the community to evaluate progress of the upcoming release and provide feedback. Please take some time to test 3.2.0pr1 and let us know what you find by filing tickets in the YUI 3 bug database marked as “Observed in version” 3.2.0pr1. We’ll do our best to address preview-release questions on the YUI 3 Forums, too.

There are three ways to get started with the preview release: YUI 3.2.0pr1 is available on the CDN via the 3.2.0pr1 version tag — so you can reference preview-release files like http://yui.yahooapis.com/combo?3.2.0pr1/build/yui/yui-min.js. If you switch to this seed file for the preview release, all subsequent use() statements will continue to load YUI 3.2.0pr1. Or You can download the full YUI 3.2.0pr1 from YUILibrary.com, including source code and examples for all components. Or you can simply explore the functioning examples roster.

Categories: Communities

New videos for Telerik WebUI Test Studio

Telerik Blogs - Tue, 07/27/2010 - 16:39

The new version of Telerik WebUI Test Studio has been out for a couple of weeks and we have already received a lot of positive feedback on the new features and improvements we have made. We have also produced a lot of new video content to help you get quickly started:

Enjoy all these videos and let us know of any feedback you have. We are always open to your ideas for new features ... and new videos.

Read more on Telerik Automated Testing Tools

Categories: Companies

Determining if an object property exists

NCZOnline - Nicholas C. Zakas - Tue, 07/27/2010 - 15:00

One of the most basic tests developers perform in JavaScript is whether or not a particular property exists on an object. Since feature detection is the preferred method of code forking, developers are encouraged to test for the existence of properties before using them. There is a lot of buggy JavaScript code out there as inexperienced developers try to use feature detection. A lot of the problems reside with a lack of understanding as to the nature of object properties in JavaScript.

Where do properties come from?

Before attempting to detect properties, it’s important to understand from where they originate. There are two basic types of properties in JavaScript: those that exist on the object (also known as “own” properties) and those that are inherited through the prototype chain (often called “prototype” properties). Consider the following:

var person = {
    name: "Nicholas"
};

alert(person.name);        //"Nicholas"
alert(person.toString());  //"[object Object]"

In this code, the object person has only one own property, which is name. You can still access other methods on the object such as toString(), but these are inherited through the prototype chain. Object literals inherit from the Object type, so all of the basic methods of Object are accessible on the instance.

The big difference between own properties and prototype properties is the difference between unique and shared values. Own properties belong to that single object instance and can’t be affected by other instances of the same type; prototype properties belong to the prototype of the object, and since the prototype can be shared amongst multiple instances, these properties are also shared amongst multiple instances. Here’s another example:

var person2 = Object.create(person);
var person3 = Object.create(person);

alert(person2.name);   //"Nicholas"
alert(person3.name);   //"Nicholas"

person.name = "Adam";

alert(person2.name);    //"Adam"
alert(person3.name);    //"Adam"

This example uses the Object.create() method from ECMAScript 5 to create two objects, person2 and person3, that inherit from person. The prototype for both person2 and person3 is person, and so name is actually a prototype property that is accessible through person2 and person3. This is why displaying the values of name on both objects results in the same value: they are both sharing the prototype property name. That means when person.name is changed directly, the change is accessible from the instances.

It’s important to understand that name is a prototype property for both person2 and person3, but it’s an own property for person. You can only assign values to own properties, so attempting to assign a value to a prototype property actually causes a new own property of the same name to be created. Example:

alert(person2.name);    //"Nicholas"
alert(person3.name);    //"Nicholas"

person2.name = "Adam";

alert(person2.name);    //"Adam"
alert(person3.name);    //"Nicholas"

Since you can’t assign to prototype properties, assigning a new value to person2.name actually creates a new own property on person2 called name. Own properties always shadow prototype properties, so the next time you access person2.name, you’re accessing the own property instead of the prototype property. That will continue until the own property is removed using delete, such as:

delete person2.name;

alert(person2.name);    //"Nicholas"

You can only call delete on an own property to remove it (calling on a prototype property does nothing). Once the own property name is removed, there is nothing shadowing the prototype property name and so person2.name now refers to the prototype property.

Note: While all native object types (Array, Boolean, Date, all Error variants, Function, Number, RegExp, and String) inherit from Object, non-native object types, such as those that represent the DOM in browsers, don’t necessarily inherit from Object in all browsers.

Detecting properties

Let’s say you want to determine if a given object has a property of name. In experienced developers tend to write code like this:

//doesn't accurately test for existence
if (person.name){
    //yay! property exists!
}

At first glance, this seems okay. However, understanding how JavaScript works reveals some problems with this approach. First, this will only succeed if the value of person.name is truthy, meaning it’s an object, a non-empty string, a non-zero number that’s not NaN, true, and not null or undefined. That means if person.name is the empty string (”"), this check will fail. Failing, in this case, doesn’t mean that the property doesn’t exist. In fact, the property does exist and contains a value, but the value is falsy and so doesn’t pass this test.

Detecting own properties

Keeping in mind that this is about testing for the existence of the property and not for the usability or data type, there are a couple of options. The first option is to detect own properties, and it comes via a method on the Object type called hasOwnProperty(). Since native objects inherit from Object, this property is inherited by these objects and can be used to detect the existence of own properties:

alert(person.hasOwnProperty("name"));   //true
alert(person2.hasOwnProperty("name"));    //false

person2.name = "Adam";

alert(person2.hasOwnProperty("name"));    //true

delete person2.name;

alert(person2.hasOwnProperty("name"));    //false

Initially, person2 has a prototype property name, so hasOwnProperty() returns false. Once an own property is created, calling hasOwnProperty() returns true. And after the property is removed via delete, this method again returns false.

JSON serialization works only for own properties, and non-native JSON serialization utilities used hasOwnProperty() to ensure that only the properties defined on object literals were included in the resulting string.

Detecting all properties

If you only care that the object has a property and don’t care whether it’s an own property or a prototype property, you can use the in operator to determine the existence of the property. Example:

if ("name" in person){
    //property exists
}

The in operator returns true when the named property exists on the object. In many cases, the in operator is all that you’ll need (especially when dealing with DOM objects). In fact, Mark Pilgrim’s All-In-One Almost-Alphabetical No-Bullshit Guide to Detecting Everything for HTML5 makes extensive use of in for detecting the new HTML5 features on DOM objects.

Conclusion

If you just want to check for the existence of properties, and not necessarily what their value might be, then you have two safe options: hasOwnProperty() and the in operator. The hasOwnProperty() property method should be used if you want to detect own properties only. If you want to test property existence and don’t care if it’s an own property or an object property, then the in operator is the one to use.

Update (27 July 2010): Added false and NaN to list of falsy values.

Update (29 July 2010): Fixed description of truthy/falsy values.
Related posts

P.S. My new book, High Performance JavaScript is now out! If you want more than performance, check out Professional JavaScript, 2nd Edition.

Categories: Blogs

How FuncUnit works

JavaScriptMVC - Tue, 07/27/2010 - 08:25

FuncUnit is a mashup of a bunch of awesome JavaScript projects.  It can be useful knowing how they all work together to make FuncUnit tick. This article details the components and how they fit together.  This is a primer for anyone wanting to contribute to FuncUnit.

FuncUnit is is comprised of the following parts:

  • Selenium - Provides browser automation
  • QUnit - A browser-based testing an assertion API.  
  • jQuery - Used for CSS selector and DOM utilities.  
  • EnvJS - A simulated browser environment.
  • Syn - A synthetic event library.

FuncUnit supports 2 modes: Browser and Selenium mode.

Browser Mode

Browser mode is when you open up your browser to a funcunit html page. This page includes the funcunit script which has inside it QUnit, jQuery, Syn and the FuncUnit API.

When you use FuncUnit (or S), it basically sends those commands to a popup window.  This is pretty straightforward.

Selenium Mode

Selenium mode is used when you use envjs to open the funcunit html page.  Here, EnvJS reads the html page and then loads and runs any script tags it finds (just like a normal browser).  But instead of sending commands to a popup window, funcunit.js starts selenium, serializes those commands, and send them to a custom Selenium server build.  The selenium server has jQuery and Syn and will run the commands the same way browser mode ran the commands.  Selenium server will return the results to FuncUnit which reports them to the console.

The Secret

Now that you know the secret to FuncUnit's awesomeness - how you are able to write a test with just a browser and funcunit.js, but automatically run it - please help us make this project even better. Here are some things we want to work on:

  • An in-browser Selenium like IDE.
  • Cucumber-like API.
  • Plugins for testing Flash / Silverlight integration.
Categories: Open Source

FuncUnit - Fun Web Application Testing

JavaScriptMVC - Tue, 07/27/2010 - 08:25

Last week we released Syn and mentioned how all testing solutions suffer from some fatal flaw. Today, we are releasing a beta of FuncUnit, which has "solved" JavaScript web application testing.

Features
  • Functional Testing - Test complex behavior like drag-drop.
  • High Fidelity - Create identical events that a mouse and keyboard create. Run tests in a real browser.
  • Automated - Test multiple browsers from the command line.
  • Easy to Write - Write, run, and debug tests in the browser, without configuring a server or other tool. Write tests in a familiar jQuery-style API.
  • Free - It's open source! Save yourself $5,000 for similar solutions.
  • Multi-system - Runs in IE 6+, FF 2+, Safari 4+, Opera 9+, Chrome, on PC, Mac, and Linux.
Download

Download FuncUnit Beta 4

What

FuncUnit is a web application testing framework that combines Selenium, jQuery, QUnit, and Envjs. It focuses on making testing as easy and fun as possible.

Writing tests is a chore and won't be done unless it's stupidly easy. Plus, tests won't get run unless they can be run automatically.

The problem with other automated testing solutions is that everyone has to install and configure cumbersome external software to even begin writing tests. After setting up the software, you write the tests with some obtuse API in a language other than JavaScript. But the worst part is debugging these tests across the software-browser bridge. The tests are almost impossible to debug!

We fixed this.

Write, Run, and Debug with the Browser

FuncUnit lets you write tests by just creating an html file that includes funcunit.js.

Simply open the html page in your browser and it runs your tests. If you made a mistake, or your app breaks, use your favorite debugger (Firebug) to catch the problem. It's easy.

Automate Your Tests

When you've setup your testing server with the browsers you want to support, running the same tests is as simple as opening the test page with envjs:

envjs http://test.myco.com/tests/filemanager.html

We typically set this up to run as a nightly build.

API

FuncUnit's API is super sweet. If you know QUnit and jQuery, it will be second nature. The following tests the handy autosuggest from phpguru. See it in action here. (Turn off your popup blocker!)

module("autosuggest",{
  setup : function(){
    S.open('autosuggest.html')
  }
});

test("JavaScript results",function(){
  S('input').click().type("JavaScript")

  // wait until we have some results
  S('.autocomplete_item').visible(function(){
    equal( S('.autocomplete_item').size(), 
           5, 
           "there are 5 results")
  })
});
Demos

Make sure you have your popup blocker off!

Documentation

JavaScriptMVC's FuncUnit docs.

Use

Setting up FuncUnit is almost exactly like setting up QUnit. After downloading FuncUnit into a public folder on your server (or a local file on your hard drive):

  1. Create an empty test script (ex: mytest.js).
  2. Create a qunit like page (ex: mytest.html) that will load your test and display your results. Use this as a template (It's also in the download).
  3. Have that page include funcunit.js, qunit.css, and your test script (mytest.js)

Open mytest.html, you should see something like:

Functemplate

*** you probably want to change the name of these files ***

Writing Tests

All interaction with the tested page is done through the FuncUnit object. This is aliased as S. S is to FuncUnit as $ is to jQuery.

Typically a test is broken down in 5 parts:

  • Opening a page
  • Performing user actions (like clicking and typing).
  • Waiting for the page to complete its response (animations and Ajax)
  • Getting properties of the page (like the text of an element)
  • Asserting the properties are correct (like the text == "Hello World")

Testing a dynamic webpage is largely asynchronous. To avoid LOTS of nested callback functions, most FuncUnit commands are queued. But  these commands take a callback function that runs after the command completes, but before the next command runs.

For example, the following performs 3 drags that each take a second.  But, between the second and third drag, it checks the #start element's text.

S("#start")
   .drag({ to:"#first", duration: 1000 })
   .drag({ to:"#second", duration: 1000 },
         function(){
            equals(S("#start").text(),"2 drops")
         })
   .drag({ to:"#third", duration: 1000 })
Opening a page

To open a page is simple. Write:

S.open("path/to/mypage.html")

The path to the page should be relative to the FuncUnit test page (mytest.html). Typically an open should be done in a module's setup function.

Actions

Actions are used to simulate user behavior such as clicking, typing, moving the mouse. FuncUnit provides the following actions:

  • click - clicks an element (mousedown, mouseup, click).
  • dblclick - two clicks followed by a dblclick.
  • rightClick - a right mousedown, mouseup, and contextmenu.
  • type - Types characters into an element.
  • move - mousemove, mouseover, and mouseouts from one element to another.
  • drag - a drag motion from one element to another.
  • scroll - scrolls an element.

The following might simulate typing and resizing a "resizable" textarea plugin:

S('textarea').click().type( "Hello World" );
  
S('.resizer').drag( "+20 +20" );
Waits

Waits are used to wait for a specific condition to be met before continuing to command. Waits look like most jQuery setter methods. For example, the following waits until the width of an element is 200 pixels and tests its offset.

var sm = S("#sliderMenu");
sm.width( 200, function(){

  var offset = sm.offset();
  equals( offset.left, 200)
  equals( offset.top, 200)
})

You can also provide a test function that when true, continues to the next action or wait command. The following is equivalent to the previous example:

var sm = S("#sliderMenu");

sm.width(
  function( width ) {
    return width == 200;
  }, 
  function(){
    var offset = sm.offset();
    equals( offset.left, 200)
    equals( offset.top, 200)
  }
)
Getters

Getters are used to test the conditions of the page. Most getter commands also correspond to a jQuery method of the same name.

The following checks that a textarea, which can only be resized vertically, is 20 pixels taller after a drag, but the same width:

var txtarea = S('textarea'),
	
    // save references to width and height
    startingWidth = txtarea.width(), 
    startingHeight = txtarea.height();

S('.resizer').drag("+20 +20", function(){
  equals(txtarea.width(), 
         startingWidth, 
         "width stays the same");
         
  equals(txtarea.height(), 
         startingHeight+20, 
         "height got bigger");
});
Assertions

FuncUnit uses qUnit for assertions so you can use:

  • ok - ok(state, message)
  • equals - equals(actual, expected, message)
  • same - same(actual, expected, message)
Running Tests

Running tests in the browser is easy - just open the FuncUnit page. But running tests via the command line is equally as easy. Simply open your test page with envjs:

envjs http://localhost/tests/grid.html

Or if you are using Mac/Linux:

./envjs http://localhost/tests/grid.html
Setting Up Your Test Server

We'll be putting this up in JavaScriptMVC's FuncUnit docs.

Conclusion

We believe FuncUnit finally makes testing JavaScript approachable. We hope you can use to to write better, more robust applications that move web development along faster than ever. If you have questions or comments please post on FuncUnit's Google Group.

Thanks!

FuncUnit is a mashup of some of the best open source tools available:

  • Selenium - Browser automation
  • QUnit - Testing API
  • jQuery - CSS selector and DOM utilities (your app does not need jQuery)
  • EnvJS - Simulated browser environment
  • Syn - A synthetic event library
Important Links
Categories: Open Source