One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex –...
Transcript of One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex –...
![Page 1: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/1.jpg)
Essentials of Testing One tool, one purpose
Bettina Polasek, Head of Quality Management Marco Cicolini, Head of Quality Engineering AdNovum Informatik AG ID 158
![Page 2: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/2.jpg)
2
Agenda
> Scope > Motivation > Toolbox > Tools for a Purpose > Demo > Experiences > Outlook > Conclusion
2
![Page 3: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/3.jpg)
3
Quality Management
3
![Page 4: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/4.jpg)
4
Scope
4
People Process
Tools
Organization
Quality Management
![Page 5: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/5.jpg)
5
Motivation
Issues - Many tools to chose from - Various advantages and disadvantages - Overlapping functionality Challenges - Finding the right tools for specific purposes - Selecting a small, but complete set of tools - Keeping the toolbox up-to-date
![Page 6: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/6.jpg)
6
Selection Criteria
Technology - Java - .NET - JavaFX - …
Layers - Web - Business - Persistence
Methodology - Static - Functional - Load, performance - Usability - Maintainability - …
![Page 7: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/7.jpg)
7
Possible Toolbox
7
![Page 8: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/8.jpg)
8
Our Toolbox
8
![Page 9: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/9.jpg)
9
Technology Management
Strategic - e.g. JEE applications Tactical - e.g. JUnit Operative - e.g. JUnit version 4.7
9
![Page 10: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/10.jpg)
10
Which Tool for which Project?
10
![Page 11: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/11.jpg)
11
How much Testing Is Enough?
11
![Page 12: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/12.jpg)
12
Demo – Application Overview
![Page 13: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/13.jpg)
13
Demo – Test Overview
13
![Page 14: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/14.jpg)
14
Demo Recap – GUI Tests
> General – Test whole application – Test use cases
> Selenium – Real browser tests – Ajax support
> HtmlUnit – Faster than Selenium – Request-based Test
> General – Slow – Fragile
> Selenium – Browser fragility
> HtmlUnit – Browser implementation
![Page 15: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/15.jpg)
15
Demo Recap – Database Tests
> General – Stable (no UI involved) – Faster than UI tests
> Embedded container – Test target container
> JPA – Fast – Test precisely what you want
> General – No UI tests possible – Database required
> Embedded container – Container specific – Slow
> JPA – No EJB interaction – Low-level API
![Page 16: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/16.jpg)
16
Demo Recap – Business Tests
> General – Very fast – Test only business logic
> JUnit – One test, one purpose
> Mockito – Mock “away” complex components – Test behavior
> General – No integration tests
> JUnit – DB and UI not testable – Test only functionality
> Mockito – Mock setup may get complex – Mocking hides missing
implementation
![Page 17: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/17.jpg)
17
Experiences – General
> Show your customer what you do. > Design simple and fast executable tests. > Decide on what and how you test (quadrants). > Have the right test distribution (testing pyramid). > Treat your test code as first class code!
17
![Page 18: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/18.jpg)
18
Experiences – Tools
> One tool, one purpose > Tools have to make testing simpler > Set up guidelines & documentation > Form experts for tools > Train developers in using tools
18
![Page 19: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/19.jpg)
19
Outlook
19
![Page 20: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/20.jpg)
20
Conclusion
> A testing toolbox is a powerful tool to focus use of resources. – Maintenance and updates at a regular basis
> Support an adequate tool for every purpose. – Focus on the test goal
> Treat your test code as first class code. – Readability, maintainability
20
![Page 21: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/21.jpg)
21
Resources
> Books • xUnit Test Patterns (EAN: 9780131495050) • Pragmatic Unit Testing (EAN: 9780974514017) • Growing Object-Oriented Software, Guided By Tests (EAN: 9780321503626) • Test-Driven Development (EAN: 9780321146533) • Agile Testing (EAN: 9780321534460)
> Tools • JUnit (www.junit.org) • Selenium (www.seleniumhq.org) • Mockito (www.mockito.org) • HtmlUnit (htmlunit.sourceforge.net) • GlassFish (glassfish.dev.java.net)
21
![Page 22: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/22.jpg)
22
Questions?
?
Visit the AdNovum booth!
22
![Page 23: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/23.jpg)
Bettina Polasek [email protected]
Marco Cicolini [email protected]
AdNovum Informatik AG www.adnovum.ch
![Page 24: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/24.jpg)
24
Additional Slides
24
![Page 25: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/25.jpg)
25
Quality Manager Role
25 25
![Page 26: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/26.jpg)
26
Demo Recap – GUI Tests
General
Test whole application Slow
Test use cases Fragile
Selenium HtmlUnit
Real browser tests Browser fragility Faster than Selenium Browser implementation
Ajax support Request-based tests
![Page 27: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/27.jpg)
27
Demo Recap – Database Tests
Tool Advantages Disadvantages
General Stable (no UI involved) No UI test possible
Faster than UI tests Database required
Embedded container Test in target container Container-specific
Slow
JPA Fast No EJB interaction
Test precisely what you want Low-level API
![Page 28: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/28.jpg)
28
Demo Recap – Business Tests
General Very fast No integration tests
Test only business logic
JUnit One test, one purpose DB and UI not testable
Test only functionality
Mockito Mock “away” complex components
Mock setup may get complex
Test behavior Mocking hides missing implementation
![Page 29: One tool, one purpose - Jazoon · 2010-06-08 · > Mockito – Mock setup may get complex – Mocking hides missing implementation . 17 Experiences – General > Show your customer](https://reader035.fdocuments.us/reader035/viewer/2022070915/5fb5ca5466dc583d5506d9e2/html5/thumbnails/29.jpg)
29
Experiences – Methodologies
> Introduce people responsible for testing > Writing tests is more than just validating features > TDD / BDD > Review your tests
29