2. WHO AM I?
• Luis Majano - Computer Engineer
• Imported from El Salvador----------->
• Architecture + Software Design
• CEO of Ortus Solutions
• Adobe Community Professional
• Creator of all things Box:
ColdBox, ContentBox,
CommandBox,WireBox….
• @lmajano, @ortussolutions
3. Why you don’t test
WhyTest
TDD
BDD
Getting jiggy with it
7. BIGGEST LIE IN SOFTWARE
Don’t worry, we will
create the tests and
refactor it later!
8.
9. Cost To Fix Time detected
Requirements Design Building Testing Post-Release
Time
Introduced
Requirements 1x 3x 5-10x 10x 10-100x
Design --- 1x 10x 15x 25-100x
Building -- -- 1x 10x 10-25x
^ Kaner, Cem; James Bach, Bret Pettichord (2001). Lessons Learned in Software Testing: A Context-Driven Approach. Wiley. p. 4. ISBN 0-471-08112-4.
BUGS COST MONEY
10. • Just do it!
• You will get dirty
• It can hurt (a little)
• Learned behavior
NO MORE EXCUSES
IT WILL ACCELERATE
YOUR DEVELOPMENT
11. What isT.D.D
Test-driven development (TDD) is a software
development process that relies on the repetition
of a very short development cycle: first the
developer writes an (initially failing) automated
test case that defines a desired improvement
or new function, then produces the minimum
amount of code to pass that test, and finally
refactors the new code to acceptable standards
14. T.D.D. IS…
• Exercises your code
• Very Developer Focused
• Developer has immediate feedback
• We will need lots of mocking
• Express some behavior and ideas
• Creates some documentation
• Sometimes it feels stupid!
function get(){
return dao.get();
}
15. T.D.D. IS NOT…
• About verifying software requirements
• Easy
• Let’s be truthful,TDD can be a pain in
the buttocks!
• We start strong, but we finish weak,
even if we finish
Developer Test
Paralysis
16. In software engineering, behavior-driven development
(BDD) is a software development process based on
test-driven development (TDD). Behavior-driven
development combines the general techniques and
principles of TDD with ideas from domain-driven
design and object-oriented analysis and design to
provide software developers and business analysts
with shared tools and a shared process to
collaborate on software development, with the aim of
delivering "software that matters"
What is BDD?
17. B.D.D isT.D.D. Evolved
• Dan North - http://dannorth.net/introducing-bdd/
• Ubiquitous language
• Existing or being everywhere at the same time : constant
• Promotes communication & collaboration
• Focuses on stories or requirements rather than on functions
• Focuses on what a system should do and not on how it should be
implemented
19. Stories to Scenarios
As an application user
I want to be welcomed with my name at login
in order to personalize my experience
Scenario: user login with valid credentials
Given a user “luis" with password "secret" exists
When I login as “luis" with "secret"
Then I should see the message "Welcome back luis!"
20. Stories to Scenarios
+Scenario 1: Account is in credit+
Given the account is in credit
And the card is valid
And the dispenser contains cash
When the customer requests cash
Then ensure the account is debited
And ensure cash is dispensed
And ensure the card is returned
21. Stories to Scenarios
Feature: Box Size
In order to know what size box I need
As a distribution manager
I want to know the volume of the box
Scenario: Get box volume
Given I have entered a width of 20
And a height of 30
And a depth of 40
When I run the calculation
Then the result should be 24000
24. Story to Scenario to
TestBox
As an application user
I want to be welcomed with my name at login
in order to personalize my experience
Scenario: user login with valid credentials
Given a user “luis" with password "secret" exists
When I login as “luis" with "secret"
Then I should see the message "Welcome back luis!"
describe( “User login with valid credentials”, function(){
it( “should see a personalized message”, function(){
userService.login( “luis”, “secret” )
var event = execute(“user.home”)
expect( event.getValue( “welcome” ) ).toBe( “Welcome back luis!” )
})
})
25. Story to Scenario to
TestBox
As an application user
I want to be welcomed with my name at login
in order to personalize my experience
Scenario: user login with valid credentials
Given a user “luis" with password "secret" exists
When I login as “luis" with "secret"
Then I should see the message "Welcome back luis!"
scenario( “User login with valid credentials”, function(){
given( “A user Luis with password secret exists”, function(){
when( “I login as ‘luis’ and ‘secret’”, function(){
then( “I should see a message ‘Welcome back luis’”, function(){
expect( event.getValue( “welcome” ) ).toBe( “Welcome back luis!” )
});});
});});
26. Story to Scenario to
TestBox
feature( "Box Size", function(){
describe( "In order to know what size box I need
As a distribution manager
I want to know the volume of the box", function(){
scenario( "Get box volume", function(){
given( "I have entered a width of 20
And a height of 30
And a depth of 40", function(){
when( "I run the calculation", function(){
then( "the result should be 24000", function(){
expect( myObject.myFunction(20,30,40) ).toBe( 24000 );
});});});});}););
27. Story to Scenario to
TestBox
story("As a distribution manager, I want to know the volume of the box I
need", function() {
given("I have a width of 20
And a height of 30
And a depth of 40", function() {
when("I run the calculation", function() {
then("the result should be 24000", function() {
expect(myObject.myFunction(20,30,40)).toBe(24000);
});
});
});
});