Published on February 15, 2014
Practicing Advanced Unit Testing with the «Trading Card Game» Kata Battlecry: Draw a slide. Deathrattle: Transform audience into 1/1 sheep. Speaker v1.11 (05.03.2014)
Kata Kata (型 or 形 literally: "form”) is a Japanese word describing detailed choreographed patterns of movements practiced either solo or in pairs.
Trading Card Game (TCG) A […] trading card game (TCG) […] is a card game that uses specially designed sets of playing cards […] mass-produced for trading or collectibility, and it must have rules for strategic game play. Acquiring these cards may be done by trading with other players or buying card packs.
Why invent another Kata? Bro, why U not use Not TDDfriendly ?? ? ? ? Rules not extensible Too easy
Hearthstone: Heroes of Warcraft®
Kata Trading Card Game
Player Setup Health 30 Mana Hand 0/0 3 4 4 4 5 5 6 6 7 8 Deck 0 0 1 1 2 2 2 3 3 3
Gameplay Receive +1 ReplenishActive Slot Mana Mana Player Pay 1 Mana 0/1 1/1 30 0/0 1 3 5 8 Play Card 1 Draw Card Cause 1 Damage 0/0 29 30 -1 3 2 2
Forced Turn Skip 30 2/2 0/1 1/1 3 5 8 2 29 3 2 2 No affordable Cards 4
Ongoing Gameplay 2/2 30 0/2 1/1 3 5 8 2 4 3 2 2 2 27 29 -2 4
Overload Rule 8/8 18 5 8 6 1 7 2 7/7 Discard Card when Hand already holds 5 Cards 12 0 8 4
Mana Cap 8 10/10 5 6 Mana is capped at 10 Slots 10/10 4 6 1
Bleedout Rule Cause 1 Damage 7 -8 10/10 1 5 6 Drawing from empty Deck 10/10 4 6 1
Game End 7 5 6 10/10 4/10 Winner! 10/10 -6 -2 4 Loser! 6 1
Kata TCG Rules & Variations https://github.com/bkimminich/kata-tcg Detailed rules description Advanced Variations Different cost & damage Healing cards Card drawer cards Use cards as Minions Deck customization
Kata TCG Sample Solution https://github.com/bkimminich/kata-tcg Java 1.8.0 Early Access Lambdas & Stream API Junit 4.11 Mockito 1.9.5 For handling dependencies of tested objects Hamcrest 1.3 Matchers for better readability in assertions System Rules 1.4.0 JUnit @Rules for substituting java.lang.System
Advanced Unit Testing Examples
Skip No-Brainers … Compile Error as Red Test Red Refactor Green
Obvious Implementation Simplest useful step Simplest possible step
Specify the Object under Test Irrelevant Details Implementation Detail Setter introduced for testing Assuming Hidden Default
Define the Object under Test Hidden default problem solved Another unwanted setter
Builder Pattern Prose-like Readability Explicitly listed Expectations …? No unnecessary details
Builder Internals Sensible Default Values Package visible full Constructor needed
Fluent API Setting properties via fluent API
Mocking Behavior Interface has no implementation yet Mock Behavior for this Test
Trashcan Refactoring CardPicker turned out to be overengineered Mocking
Mocking BDD Style Can be confused with Given-When-Then part Can be confused with Given-When-Then part
Mocking BDD Style Sugar coating for BDD syntax Matches its meaning in Given-When-Then structure
Avoid Redundancy Redundant & spoiled with Implementation Details Another slight redundancy
Avoid Constants Disturbs the reading flow
Syntactic Sugar Improves Readability and removes Redundancy
More Syntactic Sugar Magic Numbers Different Level of Abstraction
Syntactic Artificial Sweetener No-Op Syntactic Sugar for Readability Syntactic Sugar reduces Redundancy
Demo | Q&A
Demo: Test Execution Pretty fast All tests pass
Demo: Code Coverage
Demo: Human vs. AI Game Ugly Retro UI Ugly UI Player Input via System.in AI beats me! Again!
Thank you for your attention! https://twitter.com/bkimminich https://linkedin.com/in/bkimminich https://google.com/+BjörnKimminich http://slideshare.net/BjrnKimminich/
Credits Background Image: Demonplay (Permission of use granted) Other Images: Blizzard Entertainment (Permission of use requested) Wikipedia, Github, Agile Estonia Allmystery.de, Gueball.de, Natekohl.net, Scenicreflections.com Hearthstone: Heroes of Warcraft® is a trademark or registered trademark of Blizzard Entertainment, Inc., in the U.S. and/or other countries.
Practicing Advanced Unit Testing v2.3.2 (13.03.2015) withthe «Trading Card Game» Kata Battlecry:Draw a slide. Deathrattle:Transform audience into 1/1 sheep.
Doing Code Katas alone or in a Dojo can help sharpen our elementary skills as software developers. Practicing IDE shortcuts and TDD mini-step cycles is ...
Doing Code Katas alone or in a Dojo can help sharpen our elementary skills as software developers. Practicing IDE shortcuts and TDD mini-step ...
Unit Testing Slide decks. ... from Practicing Advanced Unit Testing with the TCG Kata at JavaLand 2015, 24th-25th March 2015 Added 1 year ago.
Practicing Advanced Unit Testing with the TCG Kata. Doing Code Katas alone or in a Dojo can help sharpen our elementary skills as software developers.
Unit Testing with Visual Studio. ... Practicing TDD within Visual Studio ; ... Organizing unit tests; Module 5: Advanced Unit Testing in Visual Studio
Browse Programming conferences and events around the world. ... Practicing Advanced Unit Testing with th... video for. Practicing Advanced Unit Testing ...
Learn how to write Unit Tests that helps you forward Course outline. Be more productive when practicing Test-Driven Development (TDD) by leveraging ...
Björn Kimminich - Practicing Advanced Unit Testing with the TCG Kata . 2 years ago. Anton Keks - In Agile Right Tools Matter . 2 years ago. See all . Vimeo.