Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

Commit

Permalink
Adding initial changes for #290
Browse files Browse the repository at this point in the history
  • Loading branch information
addyosmani committed Jan 27, 2013
1 parent 41a86c6 commit 3d4ab56
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 15 deletions.
Binary file modified backbone-fundamentals.epub
Binary file not shown.
5 changes: 1 addition & 4 deletions backbone-fundamentals.md
Expand Up @@ -8707,8 +8707,7 @@ The takeaway here is just to remember that if you're not (already) going through
# Unit Testing
## Unit Testing Backbone Applications With Jasmine
# Jasmine
## Introduction
Expand All @@ -8720,8 +8719,6 @@ As a basic example of unit testing is where a developer may wish to assert wheth
When building modern web-applications, it's typically considered best-practice to include automated unit testing as a part of your development process. Whilst we'll be focusing on Jasmine as a solution for this, there are a number of other alternatives worth considering, including QUnit.
## Jasmine
Jasmine describes itself as a behavior-driven development (BDD) framework for testing JavaScript code. Before we jump into how the framework works, it's useful to understand exactly what [BDD](http://en.wikipedia.org/wiki/Behavior_Driven_Development) is.
BDD is a second-generation testing approach first described by [Dan North](http://dannorth.net/introducing-bdd/) (the authority on BDD) which attempts to test the behavior of software. It's considered second-generation as it came out of merging ideas from Domain driven design (DDD) and lean software development, helping teams to deliver high quality software by answering many of the more confusing questions early on in the agile process. Such questions commonly include those concerning documentation and testing.
Expand Down
3 changes: 1 addition & 2 deletions backbone-fundamentals.rtf
Expand Up @@ -6971,7 +6971,7 @@ Backbone fundamentals
{\pard \ql \f0 \sa180 \li0 \fi0 The benefit of this is that I don\u8217't need to go pulling in jQuery UI separately to be able to take advantage of these features. Thanks to the recent ThemeRoller my components can look pretty much exactly how I would like them to and users of the app can get a jQM UI for lower-resolutions and a jQM-ish UI for everything else.\par}
{\pard \ql \f0 \sa180 \li0 \fi0 The takeaway here is just to remember that if you\u8217're not (already) going through the hassle of conditional script/style loading based on screen-resolution (using matchMedia.js etc), there are simpler approaches that can be taken to cross-device component theming.\par}
{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Unit Testing\par}
{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Unit Testing Backbone Applications With Jasmine\par}
{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Jasmine\par}
{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Introduction\par}
{\pard \ql \f0 \sa180 \li0 \fi0 One definition of unit testing is the process of taking the smallest piece of testable code in an application, isolating it from the remainder of your codebase and determining if it behaves exactly as expected. In this section, we\u8217'll be taking a look at how to unit test Backbone applications using a popular JavaScript testing framework called {\field{\*\fldinst{HYPERLINK "http://pivotal.github.com/jasmine/"}}{\fldrslt{\ul
Jasmine
Expand All @@ -6980,7 +6980,6 @@ Jasmine
{\pard \ql \f0 \sa180 \li0 \fi0 For an application to be considered \u8216'well\u8217'-tested, distinct functionality should ideally have its own separate unit tests where it\u8217's tested against the different conditions you expect it to work under. All tests must pass before functionality is considered \u8216'complete\u8217'. This allows developers to both modify a unit of code and its dependencies with a level of confidence about whether these changes have caused any breakage.\par}
{\pard \ql \f0 \sa180 \li0 \fi0 As a basic example of unit testing is where a developer may wish to assert whether passing specific values through to a sum function results in the correct output being returned. For an example more relevant to this book, we may wish to assert whether a user adding a new Todo item to a list correctly adds a Model of a specific type to a Todos Collection.\par}
{\pard \ql \f0 \sa180 \li0 \fi0 When building modern web-applications, it\u8217's typically considered best-practice to include automated unit testing as a part of your development process. Whilst we\u8217'll be focusing on Jasmine as a solution for this, there are a number of other alternatives worth considering, including QUnit.\par}
{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Jasmine\par}
{\pard \ql \f0 \sa180 \li0 \fi0 Jasmine describes itself as a behavior-driven development (BDD) framework for testing JavaScript code. Before we jump into how the framework works, it\u8217's useful to understand exactly what {\field{\*\fldinst{HYPERLINK "http://en.wikipedia.org/wiki/Behavior_Driven_Development"}}{\fldrslt{\ul
BDD
}}}
Expand Down
5 changes: 1 addition & 4 deletions chapters/11-unit-testing.md
@@ -1,7 +1,6 @@
# Unit Testing


## Unit Testing Backbone Applications With Jasmine
# Jasmine

## Introduction

Expand All @@ -13,8 +12,6 @@ As a basic example of unit testing is where a developer may wish to assert wheth

When building modern web-applications, it's typically considered best-practice to include automated unit testing as a part of your development process. Whilst we'll be focusing on Jasmine as a solution for this, there are a number of other alternatives worth considering, including QUnit.

## Jasmine

Jasmine describes itself as a behavior-driven development (BDD) framework for testing JavaScript code. Before we jump into how the framework works, it's useful to understand exactly what [BDD](http://en.wikipedia.org/wiki/Behavior_Driven_Development) is.

BDD is a second-generation testing approach first described by [Dan North](http://dannorth.net/introducing-bdd/) (the authority on BDD) which attempts to test the behavior of software. It's considered second-generation as it came out of merging ideas from Domain driven design (DDD) and lean software development, helping teams to deliver high quality software by answering many of the more confusing questions early on in the agile process. Such questions commonly include those concerning documentation and testing.
Expand Down
8 changes: 3 additions & 5 deletions index.html
Expand Up @@ -287,10 +287,9 @@ <h3>By Addy Osmani <a href="http://twitter.com/addyosmani">@addyosmani</a></h3>
<li><a href="#jquery-mobile-going-beyond-mobile-application-development">jQuery Mobile: Going beyond mobile application development</a></li>
</ul></li>
</ul></li>
<li><a href="#unit-testing">Unit Testing</a><ul>
<li><a href="#unit-testing-backbone-applications-with-jasmine">Unit Testing Backbone Applications With Jasmine</a></li>
<li><a href="#unit-testing">Unit Testing</a></li>
<li><a href="#jasmine">Jasmine</a><ul>
<li><a href="#introduction-2">Introduction</a></li>
<li><a href="#jasmine">Jasmine</a></li>
<li><a href="#suites-specs-spies">Suites, Specs &amp; Spies</a></li>
<li><a href="#beforeeach-and-aftereach">beforeEach and afterEach()</a></li>
<li><a href="#shared-scope">Shared scope</a></li>
Expand Down Expand Up @@ -7037,13 +7036,12 @@ <h3 id="jquery-mobile-going-beyond-mobile-application-development"><a href="#TOC
<p>The benefit of this is that I don’t need to go pulling in jQuery UI separately to be able to take advantage of these features. Thanks to the recent ThemeRoller my components can look pretty much exactly how I would like them to and users of the app can get a jQM UI for lower-resolutions and a jQM-ish UI for everything else.</p>
<p>The takeaway here is just to remember that if you’re not (already) going through the hassle of conditional script/style loading based on screen-resolution (using matchMedia.js etc), there are simpler approaches that can be taken to cross-device component theming.</p>
<h1 id="unit-testing"><a href="#TOC">Unit Testing</a></h1>
<h2 id="unit-testing-backbone-applications-with-jasmine"><a href="#TOC">Unit Testing Backbone Applications With Jasmine</a></h2>
<h1 id="jasmine"><a href="#TOC">Jasmine</a></h1>
<h2 id="introduction-2"><a href="#TOC">Introduction</a></h2>
<p>One definition of unit testing is the process of taking the smallest piece of testable code in an application, isolating it from the remainder of your codebase and determining if it behaves exactly as expected. In this section, we’ll be taking a look at how to unit test Backbone applications using a popular JavaScript testing framework called <a href="http://pivotal.github.com/jasmine/">Jasmine</a> from Pivotal Labs.</p>
<p>For an application to be considered <q>well</q>-tested, distinct functionality should ideally have its own separate unit tests where it’s tested against the different conditions you expect it to work under. All tests must pass before functionality is considered <q>complete</q>. This allows developers to both modify a unit of code and its dependencies with a level of confidence about whether these changes have caused any breakage.</p>
<p>As a basic example of unit testing is where a developer may wish to assert whether passing specific values through to a sum function results in the correct output being returned. For an example more relevant to this book, we may wish to assert whether a user adding a new Todo item to a list correctly adds a Model of a specific type to a Todos Collection.</p>
<p>When building modern web-applications, it’s typically considered best-practice to include automated unit testing as a part of your development process. Whilst we’ll be focusing on Jasmine as a solution for this, there are a number of other alternatives worth considering, including QUnit.</p>
<h2 id="jasmine"><a href="#TOC">Jasmine</a></h2>
<p>Jasmine describes itself as a behavior-driven development (BDD) framework for testing JavaScript code. Before we jump into how the framework works, it’s useful to understand exactly what <a href="http://en.wikipedia.org/wiki/Behavior_Driven_Development">BDD</a> is.</p>
<p>BDD is a second-generation testing approach first described by <a href="http://dannorth.net/introducing-bdd/">Dan North</a> (the authority on BDD) which attempts to test the behavior of software. It’s considered second-generation as it came out of merging ideas from Domain driven design (DDD) and lean software development, helping teams to deliver high quality software by answering many of the more confusing questions early on in the agile process. Such questions commonly include those concerning documentation and testing.</p>
<p>If you were to read a book on BDD, it’s likely to also be described as being <q>outside-in and pull-based</q>. The reason for this is that it borrows the idea of pulling features from Lean manufacturing which effectively ensures that the right software solutions are being written by a) focusing on expected outputs of the system and b) ensuring these outputs are achieved.</p>
Expand Down

0 comments on commit 3d4ab56

Please sign in to comment.