250 likes | 406 Views
FitNesse Building the right code. Trond Arve Wasskog – JavaZone’05 14.09.2005. Version 1.0. Who am I?. What is this talk about?. Waiting at the sphincter muscle…. May. Jul. Sep. Nov. Analysis. Design. ?. Implementation. Test. Source: Uncle Bob.
E N D
FitNesseBuilding the right code Trond Arve Wasskog – JavaZone’05 14.09.2005 Version 1.0
What is this talk about? Waiting at the sphincter muscle… May Jul Sep Nov Analysis Design ? Implementation Test Source: Uncle Bob
Acceptance tests and the agile rhythm Running, tested features May Jul Sep Release Iteration Test Iteration Test Iteration Test Iteration Test Iteration Test System Test
FIT Framework for Integrated Test Created by Ward Cunningham Coordinated by Jim Shore FitNesse FIT in a Wiki Created by Uncle Bob (ObjectMentor) Maintained by Micah Martin FIT and FitNesse
Acceptance Test Input Data Expected Result Acceptance Tests User Story
Test table styles and Fixtures • Query • Business rules • ColumnFixture (Fixturous Logicus) • List • Test lists of values • RowFixture (Fixturous Recordus) • Workflow • Interaction • Possibly stateful • ActionFixture (Fixturous Interactous) DEMO: <Alt>-<Tab>
FitLibrary – Rick Mugridge • Fixtures for actions (workflow): • DoFixture • SequenceFixture (mostly the same as DoFixture) • Fixtures for lists: • ArrayFixture - ordered lists • SetFixture - unordered lists • SubsetFixture for parts of unordered lists • ParamRowFixture to simplify the use of RowFixture with other FitLibrary fixtures • Fixture for calculations: • CalculateFixture • Fixture for set up: • SetUpFixture
Project examples • http://localhost/JavaZone.ProjectExamples
Include FitNesse in test and CI cycle! • Reduce the feedback loop • Developers must pay attention to acceptance tests
Structure and configuration Latest version of application and database Stable application and database FitNesse Root Stable Config Developer Config All Tests Approved Tests Suite of all approved tests run in CI cycle Root of all FitNesse tests Feature 1 Suite Feature 1 Test 1 Feature 1 Test 2 Feature 2 Suite Configuration Test Suite Feature 2 Test 1 Test Feature 2 Test 2 Subpage Symlink
Running FitNesse from the command line • CommandLineRunner • Ant • Debugging • Maven plugin • Note • Using client classpath • ... but server FitNesse server test tables • ... and variables defined on the server
A word about GUI/WebUI testing... • Don’t do it! • Hard to understand and maintain • Brittle • Slow • Hard to test-drive • If you really must... • FitNesse • JWebFit - JWebUnit • HtmlFixture – HtmlUnit • Canoo WebTest • Selenium • Watir • Test as much as possible on the backside
What is this really about? • Communication, Feedback and Collaboration • Customer involvement • Specification instead of Verification • Building the right code • Agile development • Running, tested features • Delivering business value • Iterations • Know when you are done • Measuring progress and velocity • Regression testing
C’est tout Thank you very much for listening to me! Questions? Now get out and start writing FitNesse acceptance tests! Feel free to contact me: trond.arve.wasskog[AT]bekk.no
Hints & Tips • FitNesse - Excel • Refactoring FitNesse • !path • Use / (forward-slash) • No Spaces in paths • System properties • Version control • Built-in • File system
Resources • Fit for Developing Software – Rick Mugridge/Ward Cunningham • http://www.amazon.com/exec/obidos/tg/detail/-/0321269349/102-7666705-8612148?v=glance • FIT • http://fit.c2.com • FitNesse • http://www.fitnesse.org/ • http://groups.yahoo.com/group/fitnesse/ • FitLibrary • http://fitlibrary.sourceforge.net/ • http://www.cs.auckland.ac.nz/~rick/FitLibrary/
Developer tips • Database tests • Start a transaction in a DoFixture setup • Perform the required database setup • Execute the tests • Roll back the transaction • Mocks and stubs • Use mocks and stubs to focus coherent tests • Transactions and mocking is easy using Spring
TypeAdapters • TypeAdapters support domain types in tests • String to domain objects • Domain objects to Strings • Test for equality • Built-in type adapters for primitives and wrappers • Three ways to add TypeAdapters • Add a public Object parse(String s, Class type) in your Fixture • Add a public static <Type> parse(String s) in your domain object • Uses toString() and equals() • FitNesse only • LibraryTypeAdapter.registerParseDelegate( Class type, Object parseDelegate) • FitLibrary Fixtures only • New plugin architecture underway
FIT vs FitNesse • FIT runs HTML tables • Must be run from the command line • FitNesse is more dynamic • Easy to specify and execute tests • Wiki • Widgets • Symbolic Links • Must copy and paste from Excel