Unit Test/JUTE Workshop

Mark Ethan Trostler trostler@yahoo-
             inc.com
             @zzoass
Minimize Your Pain

•Write Small
•Write Simple
•Test Early
•Test Often
Write Small – Write Simple

•Isolate code to test
•Loosely couple dependencies
•Be obvious
•Optimize last
Test Early – Test Often



       Test Now
Install JUTE

•NodeJS (nodejs.org)
•npm (curl http://npmjs.org/install.sh | sh)
•JUTE (npm install jute –g)

       Yahoo’s: % yinsti –b test jute
Write Some Tests!



http://yuilibrary.com/yui/docs/test/
What To Test
     Your Function/Method ONLY!!

Mock/Manage Dependencies:
•Explicit
•Internal
•Environment
Run In Browser



Load up your HTML & let it fly!
Run Within JUTE - Browser

% npmconfig set jute:<variable><value>
%....
% yinst restart jute –g

Load JUTE web UI & run some tests!
Run Within JUTE – Command line

% jute_submit_test –test ….

In parallel each captured browser runs
every test
Run Within JUTE – Selenium

Grab latest selenium-server-standalone
% java –jar selenium…
% jute_submit_test –sel_host<> --test …

Serialized tests
Run Within JUTE – V8


% jute_submit_test –v8 <> --test …

Serialized tests
Run Within JUTE – Selenium Grid
% jute_submit_test –sel_host<> --
seleniums 5 --test …

Tests in ‘seleniums’ chunks to each
Selenium slave in parallel.

Will block if you don’t have enough slaves!
Keep Writing Those Tests!!



Yahoo wants 75% coverage!

JUTE Workshop

Editor's Notes

  • #3 Get manager-speak out of the wayYou have heard all of this before from industry – from manager – from co-workers - there’s a reason: less pain for you – less pain for you managers – better codeWhy everyone all up in me about these things?You probably already agree it’s a good thingmanagers NEED you to succeedSmall = testableSimple = testable – minimize side effects – side effects harder to test – harder to capture – harder to explain
  • #4 Lots of little – no bigPer function – test ONE THING AT A TIMEDo no create - injectIsolate what you want to testMocking out dependenciesCreating causes tight couplingClever comes later – if at all – don’t get cute or too clever – optimize LATER
  • #5 NOWDon’t have to test first -
  • #6 NOWDon’t have to test first -
  • #7 NOWDon’t have to test first -
  • #8 NOWDon’t have to test first -
  • #9 NOWDon’t have to test first -
  • #10 NOWDon’t have to test first -
  • #11 NOWDon’t have to test first -
  • #12 NOWDon’t have to test first -
  • #13 NOWDon’t have to test first -
  • #14 NOWDon’t have to test first -
  • #15 NOWDon’t have to test first -