test essentials @mdevcon 2012
TRANSCRIPT
![Page 1: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/1.jpg)
Test EssentialsDeveloper Perspective
![Page 3: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/3.jpg)
itemis AGMDSD!
OpenSource!Eclipse!Agile!Mobile
![Page 4: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/4.jpg)
What‘s your deal?
iOS!Android!
WP7!WebDeveloper
![Page 5: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/5.jpg)
Why should we test?
document your intentions!eat your own dog food!confidence by feedback!
safe refactoring!debugging
![Page 6: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/6.jpg)
How can we test?
![Page 7: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/7.jpg)
Test FirstRed, Green, Refactor!Goes perfect with Unit
Testing and Pair Programming
![Page 8: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/8.jpg)
Test AfterWhite Box Testing!
It is better than nothing!!And sometimes even necessary:!
Regression Test!Integration Test!
Acceptance Test (UI/UX Test)
![Page 9: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/9.jpg)
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
![Page 10: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/10.jpg)
Test to explore
!
Example driven development!
Update safely to newer versions
![Page 11: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/11.jpg)
What do we need for testing?
DSL to define the test!Runner to execute the test!
Reports to visualize results
![Page 12: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/12.jpg)
Test Frameworks forms the DSL
![Page 13: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/13.jpg)
xUnit Frameworks
Class is a test case!
Each public „test“ Method is a single test!
Test case may hold state, setup and tear down methods
Kent Beck
![Page 14: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/14.jpg)
JUnit / OCUnithttp://www.junit.org/
![Page 15: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/15.jpg)
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
![Page 16: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/16.jpg)
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
![Page 17: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/17.jpg)
Mockitohttp://code.google.com/p/mockito/
![Page 18: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/18.jpg)
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
![Page 19: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/19.jpg)
Hamcrest Matcherhttp://code.google.com/p/hamcrest/
![Page 20: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/20.jpg)
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“)
![Page 21: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/21.jpg)
Behavior Driven
DevelopmentIt‘s all about
Communication!don‘t test!
specify your code
Dan North
![Page 22: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/22.jpg)
BDD Frameworks
There are two main flavors behind BDD Frameworks:!
Describe what you expect it should do (RSpec family)!
Given/When/Then (Cucumber family)
![Page 23: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/23.jpg)
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
![Page 24: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/24.jpg)
Jasmine Spechttp://pivotal.github.com/jasmine/
![Page 25: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/25.jpg)
Kiwihttps://github.com/allending/Kiwi
![Page 26: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/26.jpg)
Given/When/Then
Breaks down into:!
Feature!
User story!
Scenario!
Steps (Given/When/Then)
![Page 27: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/27.jpg)
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
![Page 28: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/28.jpg)
Scenario definition
![Page 29: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/29.jpg)
JBehave Stepshttp://jbehave.org/
![Page 30: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/30.jpg)
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
![Page 31: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/31.jpg)
UI Test Framework
Selenium!
KIF!
UIAutomation!
Zucchini Framework
![Page 32: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/32.jpg)
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
![Page 33: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/33.jpg)
One small advice: If you can record and
replay a test case. Just Don‘t!
![Page 34: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/34.jpg)
Zucchini Frameworkhttp://www.zucchiniframework.org/
![Page 35: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/35.jpg)
Zucchini Framework
![Page 36: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/36.jpg)
Zucchini Report
![Page 37: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/37.jpg)
Zucchini Report
![Page 38: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/38.jpg)
I hope I could convince you that Test is important
and exciting
![Page 39: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/39.jpg)
Some concepts as Military Metaphors
![Page 40: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/40.jpg)
Leave no men behind
100% code coverage
![Page 41: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/41.jpg)
Protect your rear(back)
Test protects you from butterfly effect
![Page 42: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/42.jpg)
Sniper vs. Cluster Bomb
Unit vs. Integration Test
![Page 43: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/43.jpg)
Q&A
![Page 44: Test Essentials @mdevcon 2012](https://reader033.vdocuments.net/reader033/viewer/2022052906/558c6899d8b42ac9508b4613/html5/thumbnails/44.jpg)
Thank you!!!We are consulting :)