Testing Storm components with Groovy and Spock

Post on 30-Nov-2014

1.163 views 1 download

description

Ho to use Groovy and Spock framework for testing Java projects. Examples of using Storm testing facility.

Transcript of Testing Storm components with Groovy and Spock

TESTING STORM COMPONENTSWITH GROOVY AND SPOCK

About Me

Architect @WebMD

Java Developer

Big Data and NoSQL enthusiast

NYC Storm meetup organizer

@edvorkin

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"

How to make testing Java applications easy and fast?

"It works on my machine"

Groovy - more productive Java

Compiles to byte code

Easy to pick up by Java developers

Reuse of Java semantics and API

Concise syntax

Concise syntax

Differences from Java

Optional typing

Optional Exception handling

Optional parentheses

meta programming

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.

Groovy CollectionsA lot of syntax sugar and convenience methods on collections

JsonSlupper and XmlSlupper

Builders - Xml, Json, HTTP

Easy to work with SQL

IDE Support

How to get started?

How to get started?

Write tests!

Not a production code, easy to get approval.

WHICH TESTING FRAMEWORK CAN I USE

WITH GROOVY?

SPOCK - BEHAVIOR-DRIVEN TESTING FRAMEWORK

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

BDD Style

BDD Style

Mock and Interaction verification

StubbingStubbing is the act of making collaborators respond to method calls in a certain way.

Testing Storm components

Testing Storm components

Bolt under the test

Demo

Test Code

Test Code

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

Resources

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

THANKS.