98
ThoughtWorks ThoughtWorks NEAL FORD software architect / meme wrangler ThoughtWorks [email protected] 3003 Summit Boulevard, Atlanta, GA 30319 www.nealford.com www.thoughtworks.com blog: memeagora.blogspot.com twitter: neal4d unit testing that sucks less: small things that make a big difference

unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

ThoughtWorksThoughtWorks

NEAL FORD software architect / meme wrangler

ThoughtWorks

[email protected] 3003 Summit Boulevard, Atlanta, GA 30319

www.nealford.com

www.thoughtworks.com

blog: memeagora.blogspot.com

twitter: neal4d

unit testing that sucks less: small things that make a

big difference

Page 2: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

housekeepingask questions anytime

download slides from nealford.com

download samples from github.com/nealford

Page 3: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

groovymockrunner

jruby mockingjtestr & rspec

easyb

jesterinfinitesthamcrest

what i cover

Page 4: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

http://code.google.com/p/hamcrest/

Page 5: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

the test target

Page 6: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

the old way

thou shalt assert equals expected and f.factors

Page 7: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

included in junit 4.x, addable for junit 3.x

fluent interface matchers for xUnit

syntactic sugar for standard matchers

make assertions suck less

not a testing framework

hamcrest matchers

Page 8: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

hamcrest: equalTo

Page 9: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

hamcrest: is(equalTo...

Page 10: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

hamcrest: is

Page 11: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

hamcrest: anything

Page 12: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

hamcrest: anyOf

Sucks

Less!

Page 13: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

http://code.google.com/p/infinitest/

Page 14: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

it picks tests intelligently

continuous test runner for junit tests

whenever you change a class, infinitest runs tests for you

plug-in for eclipse or intellij

compiler-like verification for unit tests

Page 15: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

configuring intellij

Page 16: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

infinitest in intellij

Page 17: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

select the "Available Software" tab, and hit "Add Site..."

copy the update url to your clipboard: http://www.infinitest.org/eclipse-update

In eclipse, choose the Help->Software Updates menu item

choose the appropriate version of Infinitest by checking the box to the left, & hit "Install"

paste the update URL into the "Location" field, and hit "OK"

configuring eclipse

Page 18: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

infinitest in eclipse

Sucks

Less!

Page 19: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

http://jester.sourceforge.net/

Page 20: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

makes changes to your tests

test permutation framework

jester:

hopes the tests fail

rebuilds the code

Page 21: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

BUILD_COMMAND is the command to build your project and run tests

only run jester on a copy of your files!

java jester.TestTester BUILD_COMMAND SOURCE_DIRECTORY

produces an xml report

SOURCE_DIRECTORY is the source directory for your tests

Page 22: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

running jester

Page 23: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

python makeWebView.py

jester produces an xml output file

includes a python script to output each changed file to html

shows what was changed

produces a friendly report

reporting results

Page 24: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319
Page 25: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319
Page 26: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

poor tests

Page 27: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319
Page 28: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

improved code

Sucks

Less!

Page 29: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

http://mockrunner.sourceforge.net/

Page 30: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

includes a JDBC, a JMS and a JCA test framework

lightweight framework for unit testing applications in the J2EE environment

supports servlets, filters, tag classes and Struts actions and forms

write very sophisticated unit-tests for J2EE based applications without any overhead

extends junit and simulates the necessary behavior without calling the real infrastructure

Mockrunner

Page 31: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

testing struts actions

Page 32: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

extending BasicActionTestCaseAdapter

Page 33: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

delegator

Page 34: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

testing servlets

Page 35: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319
Page 36: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

testing HTML using JDOM

Page 37: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

testing jdbc

Page 38: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

testing transactions

Page 39: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

mocking JMS

Page 40: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

creating the fixture

Page 41: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

the test

Page 42: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319
Page 43: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

stubbing via inheritance

Page 44: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

mockrunner is fast!

Sucks

Less!

Page 45: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

http://unitils.org/

Page 46: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

mock objects

open source set of utility classes to make typical java scenarios easier to test

offers support to hibernate, spring, JPA

spring integration

persistence layer testing support

Page 47: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

assertion utilities

asserting user1 == user2

Page 48: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

testing identityequals

method in User

what is tested?

more comprehensive

Page 49: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

reflection assertions

loops over all fields in both objects and compares their values using reflection

Page 50: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

lenient assertions

Page 51: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

dbUnit supportdbUnit files to be

loaded for this test

Page 52: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

dbUnit support

this data will be loaded prior to test run

firstname == null

Page 53: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

hibernate support

Page 54: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

injection of Spring beans in unit tests

sometimes useful to have spring around during testing

management of ApplicationContext configuration

reference the Unitils DataSource in Spring configuration

make use of a hibernate SessionFactory configured in Spring

spring support

Page 55: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

spring support

ApplicationContext

injection

Page 56: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

mocksauto creation

of mocks

expectations

verification

Sucks

Less!

Page 57: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

http://code.google.com/p/spock/

Page 58: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

nicely detailed error messages

testing & specification framework for Java & Groovy

highly expressive specification language

compatible with junit test runner

setup - stimulus - response - cleanup

spock

Page 59: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

spock test specification

junit test runner interface

test classtest

stimulus

response

Page 60: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

blocks & outcomes

Page 61: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

setup

simple statements

of fact

Page 62: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

pretty failures!

Page 63: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

junit vs. spock

Sucks

Less!

Page 64: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

tdd private methods?

Page 65: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319
Page 66: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

solution #1:

make them all public(or package) scope

Page 67: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

solution #2:

use reflection

Page 68: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

reflection helpers

Page 69: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

groovy

Page 70: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

reflection

Page 71: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

dirty secret:private is ignored!

technically, a bug......no great hurry to fix it (insanely useful!)

Page 72: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

mocking

Page 73: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

mocking in

Page 74: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

FactorsFinder class harvests factors

Classifier uses external factors

changes:

Finder

FactorsFinder

Finder

FactorsFinder

Classifier

Page 75: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319
Page 76: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319
Page 77: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

jmock

Sucks

!

Page 78: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

mocking with

Page 79: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

java-like syntax

Page 80: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

factors :factors :

factors()

Finder

Page 81: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

idiomatic

Page 82: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

Sucks

Less!

Page 83: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

http://jtestr.codehaus.org/

Page 84: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

testing java with jruby

Page 85: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

the java part

Page 86: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

testing fill()

Page 87: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

jmock

Page 88: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

mocha

Sucks

Less!

Page 89: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

what does it take???

Page 90: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

jmock vs mocha loc

0

4,000

8,000

12,000

16,000

20,000

17,152

2,245JMock

mocha

jmock has 7.5 times as many lines of code

Page 91: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

jmock vs mocha cc

0

600

1,200

1,800

2,400

3,000

2,349

323JMock

mocha

jmock has 7.2 times the complexity of mocha

Page 92: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

...that execute

behavior driven development framework

allows you to create readable specifications...

inspiration for tons of similar frameworks

inspired by JBehave

rspec

Page 93: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

specification

Page 94: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319
Page 95: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

pretty results

Page 96: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

Sucks

Less!

Page 97: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319

ThoughtWorks

This work is licensed under the Creative Commons Attribution-Share Alike 3.0 License.

http://creativecommons.org/licenses/by-sa/3.0/us/

?’splease fill out the session evaluationssamples at github.com/nealford

NEAL FORD software architect / meme wrangler

ThoughtWorks

[email protected] 3003 Summit Boulevard, Atlanta, GA 30319

www.nealford.com

www.thoughtworks.com

blog: memeagora.blogspot.com

twitter: neal4d

Page 98: unit testing that sucks less - Oracle...ThoughtWorks NEAL FORD software architect / meme wr angle r Thought Works nf ord@thoughtw orks.com 3003 Summit Boule vard, Atlanta, GA 30319