testing storm components with groovy and spock
DESCRIPTION
Ho to use Groovy and Spock framework for testing Java projects. Examples of using Storm testing facility.TRANSCRIPT
![Page 1: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/1.jpg)
TESTING STORM COMPONENTSWITH GROOVY AND SPOCK
![Page 2: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/2.jpg)
About Me
Architect @WebMD
Java Developer
Big Data and NoSQL enthusiast
NYC Storm meetup organizer
@edvorkin
![Page 3: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/3.jpg)
Testing is annoying to the typical programmer.
Programmers are driven to create things, build products, add features, and make things work.
Testing is just the opposite. It's about finding weaknesses, exploiting edge cases and making it breaks.
"It works on my machine"
![Page 4: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/4.jpg)
How to make testing Java applications easy and fast?
"It works on my machine"
![Page 5: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/5.jpg)
Groovy - more productive Java
Compiles to byte code
Easy to pick up by Java developers
Reuse of Java semantics and API
![Page 6: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/6.jpg)
Concise syntax
![Page 7: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/7.jpg)
Concise syntax
![Page 8: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/8.jpg)
Differences from Java
Optional typing
Optional Exception handling
Optional parentheses
meta programming
![Page 9: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/9.jpg)
Lambdas -> Closures• Closures are blocks of code that can be treated as
first-class objects: passed around as references, stored, executed at arbitrary times, and so on.
![Page 10: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/10.jpg)
Groovy CollectionsA lot of syntax sugar and convenience methods on collections
![Page 11: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/11.jpg)
JsonSlupper and XmlSlupper
Builders - Xml, Json, HTTP
![Page 12: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/12.jpg)
Easy to work with SQL
![Page 13: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/13.jpg)
IDE Support
![Page 14: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/14.jpg)
How to get started?
![Page 15: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/15.jpg)
How to get started?
Write tests!
Not a production code, easy to get approval.
![Page 16: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/16.jpg)
WHICH TESTING FRAMEWORK CAN I USE
WITH GROOVY?
SPOCK - BEHAVIOR-DRIVEN TESTING FRAMEWORK
![Page 17: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/17.jpg)
Spock Testing Framework
Expressive testing language
Easy to Learn
Reduce the line of test code
Leverage Groovy
Productivity
Structural blocks - BDD style -context, stimulus, expectation
![Page 18: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/18.jpg)
BDD Style
![Page 19: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/19.jpg)
BDD Style
![Page 20: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/20.jpg)
Mock and Interaction verification
![Page 21: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/21.jpg)
StubbingStubbing is the act of making collaborators respond to method calls in a certain way.
![Page 22: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/22.jpg)
Testing Storm components
![Page 23: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/23.jpg)
Testing Storm components
![Page 24: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/24.jpg)
Bolt under the test
![Page 25: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/25.jpg)
Demo
![Page 26: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/26.jpg)
Test Code
![Page 27: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/27.jpg)
Test Code
![Page 28: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/28.jpg)
Some ideas
Treat Storm components as regular functions
Use backtype.storm.Testing
Use Spock Mocks, Stubs and Interactions
https://github.com/xumingming/storm-lib/blob/master/src/jvm/storm/TestingApiDemo.java
![Page 29: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/29.jpg)
Resources
![Page 30: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/30.jpg)
Resources
http://docs.spockframework.org/en/latest/
http://groovy.codehaus.org/
http://vimeo.com/43808772 - Venkat Subramaniam - Caring about Code Quality
Storm Real-time Processing Cookbook by Quinton Anderson
![Page 31: Testing Storm components with Groovy and Spock](https://reader031.vdocuments.net/reader031/viewer/2022020920/547ce4ff5806b50d408b4879/html5/thumbnails/31.jpg)
THANKS.