Test Essentials
 Developer Perspective
Maxim
  Zaks
   @iceX33!
zaks@itemis.de
itemis AG
    MDSD!
 OpenSource!
   Eclipse!
    Agile!
   Mobile
What‘s your
  deal?
      iOS!
    Android!
      WP7!
  WebDeveloper
Why should
  we test?
document your intentions!
 eat your own dog food!
confidence by feedback!
    safe refactoring!
       debugging
How can we test?
Test First
Red, Green, Refactor!
Goes perfect with Unit
  Testing and Pair
    Programming
Test After
       White Box Testing!
   It is better than nothing!!
And sometimes even necessary:!
         Regression Test!
        Integration Test!
 Acceptance Test (UI/UX Test)
Test because
 you have a
 test phase
           !
  Just don‘t do that!!
Code have to be written
   with Test in mind!
 Black Box Test = QA
Test to
    explore
           !
   Example driven
    development!
Update safely to newer
       versions
What do we
  need for
  testing?
  DSL to define the test!
Runner to execute the test!
   Reports to visualize
          results
Test Frameworks forms
        the DSL
xUnit Frameworks
Class is a test
case!

Each public „test“
Method is a single
test!

Test case may
hold state, setup    Kent Beck

and tear down
methods
JUnit / OCUnit
 http://www.junit.org/
What we should keep
in mind using xUnit
 Test Methods should be atomic, as we don‘t
 know the order they will be executed!

 Test methods should be simple. No
 Conditions and no loops!

 Method and class names are used for
 reporting!

 Consider to use mocking and matching
 frameworks to make tests more concise
What‘s mocking all
      about?
 Unit testing is all about isolation!

   We wan‘t to test a boss who depend on
   his assistant!

   We provide him a spy assistant and
   monitor how he interacts!

 Dependency Injection is the concept that
 let us do isolation in non dynamic
 language
Mockito
http://code.google.com/p/mockito/
And what was it
 with matching?
Matchers let us express expectations
in a very concise way!

Matchers will generate a pretty
report when expectation is not
fulfilled!

Matching framework let us define
our own matchers
Hamcrest Matcher
http://code.google.com/p/hamcrest/
What‘s wrong with
      xUnit
xUnit Frameworks are the basis for
Test Driven Development!

Perfect from technical perspective!

But hard to use for communication
(remember: „document your
intensions“)
Behavior
   Driven
Development
   It‘s all about
  Communication!
     don‘t test!
 specify your code

                     Dan North
BDD Frameworks

There are two main flavors behind
BDD Frameworks:!

 Describe what you expect it
 should do (RSpec family)!

 Given/When/Then (Cucumber
 family)
describe what you
expect it should do
 Internal DSL which let you write
 executable or pending specifications!

 Good fit for Unit testing!

 Comes with mocking and matching
 solutions inside!

 Let you define nonlinear context
 creation
Jasmine Spec
http://pivotal.github.com/jasmine/
Kiwi
https://github.com/allending/Kiwi
Given/When/Then

Breaks down into:!

  Feature!

  User story!

  Scenario!

  Steps (Given/When/Then)
External DSL

Given/When/Then frameworks
work perfectly with external DSLs!

These frameworks can evaluate
Plain Text, Wiki Pages or Excel
spread sheets and execute the steps
Scenario definition
JBehave Steps
 http://jbehave.org/
Let‘s sum up on
Testing Frameworks
 xUnit Frameworks (with handy
 helpers)!

 Describe what you expect it should do!

 Given/When/Then!

 And as always there is one more
 thing, UX/UI Testing
UI Test Framework

 Selenium!

 KIF!

 UIAutomation!

   Zucchini Framework
UX / UI Testing

Launch the application in the runtime!

Select UI element!

Perform actions!

Wait for UI component to appear!

Assert visual or structural
appearance
One small advice:
If you can record and
  replay a test case.
      Just Don‘t!
Zucchini Framework
http://www.zucchiniframework.org/
Zucchini Framework
Zucchini Report
Zucchini Report
I hope I could
convince you that
Test is important
  and exciting
Some concepts as
Military Metaphors
Leave no men
   behind
 100% code coverage
Protect your rear                  (back)




Test protects you from butterfly effect
Sniper vs. Cluster
      Bomb
  Unit vs. Integration Test
Q&A
Thank you!!!
 We are consulting :)

Test Essentials @mdevcon 2012