You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: backbone-fundamentals.md
+1-4
Original file line number
Diff line number
Diff line change
@@ -8707,8 +8707,7 @@ The takeaway here is just to remember that if you're not (already) going through
8707
8707
8708
8708
# Unit Testing
8709
8709
8710
-
8711
-
## Unit Testing Backbone Applications With Jasmine
8710
+
# Jasmine
8712
8711
8713
8712
## Introduction
8714
8713
@@ -8720,8 +8719,6 @@ As a basic example of unit testing is where a developer may wish to assert wheth
8720
8719
8721
8720
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.
8722
8721
8723
-
## Jasmine
8724
-
8725
8722
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.
8726
8723
8727
8724
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.
Copy file name to clipboardexpand all lines: backbone-fundamentals.rtf
+1-2
Original file line number
Diff line number
Diff line change
@@ -6971,7 +6971,7 @@ Backbone fundamentals
6971
6971
{\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}
6972
6972
{\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}
6973
6973
{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Unit Testing\par}
6974
-
{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs32 Unit Testing Backbone Applications With Jasmine\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
6977
6977
Jasmine
@@ -6980,7 +6980,6 @@ Jasmine
6980
6980
{\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}
6981
6981
{\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}
6982
6982
{\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 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
Copy file name to clipboardexpand all lines: chapters/11-unit-testing.md
+1-4
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,6 @@
1
1
# Unit Testing
2
2
3
-
4
-
## Unit Testing Backbone Applications With Jasmine
3
+
# Jasmine
5
4
6
5
## Introduction
7
6
@@ -13,8 +12,6 @@ As a basic example of unit testing is where a developer may wish to assert wheth
13
12
14
13
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.
15
14
16
-
## Jasmine
17
-
18
15
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.
19
16
20
17
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.
<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>
7038
7037
<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>
<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>
7043
7042
<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>
7044
7043
<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>
7045
7044
<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>
7046
-
<h2 id="jasmine"><a href="#TOC">Jasmine</a></h2>
7047
7045
<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>
7048
7046
<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>
7049
7047
<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>
0 commit comments