We all agree that having well tested apps is important, right? In an agile environment it gives you the confidence to iteratively refactor as requirements change. And the larger your application, the more important this becomes. Not only does it promote quality, but also a scalable application architecture that's essential when building "Ginormous JavaScript Apps".
In this talk I'll discuss and demonstrate how testing has been core to Caplin Systems successfully building and maintaining a 100k+ LoC front-end JavaScript SDK and multiple 50k+ LoC apps. In particular, the application architecture required to enable testing apps of this size.
10. Application ATs
• Selenium Tests
• Selenium User-Extensions
• Actions, Accessors/Assertions & Locators
• VM infrastructure for CI
#sjsPhilL
11. 3
3. Launch browser + App
AT Process
#sjsPhilL
1
1. Pair Browser + Backend VM
2
2. Reset & restart backend services
5
5. Record results
4
4. Execute ATs
6
6. Reset backend services
8. Execute next test…
8
7
7. Restart/refresh browser
12. Test Results
• ~1300 UTs
• ~500 ATs
• 50 pairs - VM infrastructure to parallelise tests
#sjsPhilL
• 8 Hours
• We could only run a full suite of
tests once per day - at night
• Test results highly unreliable
http://paintballkitty.spreadshirt.com/sad-dinosaur-A11954669
13. We Were Doing It
Wrong!
https://www.flickr.com/photos/41187064@N03/3809454959/in/gallery-dreamyshade-72157622839898770/
#sjsPhilL
30. Setting & Getting Services
• Use a unique identifier for each service
• Register (code or config). Code example:
!
• Get
http://martinfowler.com/articles/injection.html#ADynamicServiceLocator
#sjsPhilL
40. End-to-End Feature Testing
• Testing features in
isolation
• Change view model
and assert against
mocked Service
• Inject fake service,
make calls and assert
View Model
#sjsPhilL
43. How Do You Test Ginormous
JavaScript Apps?
Have an Architecture Built for Testing
1. Components/Widgets/Modules
2. A Services Layer
3. MVVM - Don’t touch that DOM
#sjsPhilL
Supersaurus
http://www.cfsl.net/forums/viewtopic.php?f=39&t=19496