Sencha Roadshow 2016: Sencha Test by Don Griffin
View Slide
© 2016 Sencha Inc.Sencha Test!Improving Web App Quality!!By!Don Griffin!Director of Engineering!
© 2016 Sencha Inc.What We’ll Cover!• History / Backstory!• Test Types and their challenges!• Where does Sencha Test fit?!• Sencha Test highlights!• Demo!3!
© 2016 Sencha Inc.Backstory!
© 2016 Sencha Inc.Backstory!• Sencha got really serious about automated testing with Ext JS 4!- Over 5 years ago!• Combined various tools!- Jasmine, Team City, WebDriver, Istanbul, Siesta, Sauce Labs!• Across the test spectrum!- Unit tests!- Integration (component) tests!- Application tests (for our examples, etc.)!- Visual testing for CSS issues!5!
© 2016 Sencha Inc.Testing In Sencha Today!• Tests are run…!- On each pull request before merging!- Against main branches after merge!• Tests are run on IE8-11, Edge, Firefox, Chrome, Safari, iPad etc..!- Multiplied out that comes to 330,000 test executions per run!- With code coverage on most branches!• QA team!- Runs automated tests on apps and examples using nightly builds!6!
© 2016 Sencha Inc.Common Challenges!• I fixed that bug…!- How did it break again?!?!• It is hard to write asynchronous tests…!- I’ll add some when I have more time.!• It works on my machine…!- But fails in the CI run!!• How do I test my code…!- In the same way the CI does?!• The tests all pass….!- But things don’t look right!!7!
© 2016 Sencha Inc.Test Types!
© 2016 Sencha Inc.TestEngineer DeveloperTest Types!1. Unit Tests!- Creating class instances, calling methods directly!- No User Interface involved!2. Integration Tests!- Isolated instances of Components, Views and Controllers!- Mock dependencies!3. Application Tests!- Launch application!- Interact with the UI and check results!9!
© 2016 Sencha Inc.Test Types!10!Integration Tests Application TestsUnit Tests• Easy to write!• Fast execution!• Immediate feedback!• More complex!• Slower to run!• Typically async!• Isolation can be tricky!• Mocking is tricky!• Hardest to write!• Tedious to run!- Require installed app!- Server environment!• Data / Results hard tomake predictable!
© 2016 Sencha Inc.Comparing Test Types!11!Integration Tests Application TestsUnit Tests• Yes!• Developer!• Developer!• Yes!• Developer!• Developer!• Yes!• Test Engineer!• Test Engineer!Necessary!Author!Run By!Problem
© 2016 Sencha Inc.Ideal Mix!12!AppIntegrationUnit
© 2016 Sencha Inc.Typical Case!13!App?developersboss?!?#$@!customers
© 2016 Sencha Inc.Sencha Test!
© 2016 Sencha Inc.Sencha Test!• Productizes Sencha’s testing experience!• Common request from customers!• One place for the dev and QA team to collaborate!- Because it handles unit, integration and application testing!• First release covers the essential workflows!15!
© 2016 Sencha Inc.Web AppArchitecture Overview!16!– or –h,p h,ph,ptest/*
© 2016 Sencha Inc.Sencha Test Essentials!• Understands Sencha application structure!- Works seamlessly with Cmd-based projects!- Works with any web app that has a URL!• Test configuration performed in Sencha Studio is used to…!- Run tests directly in Sencha Studio!- Run tests via the Sencha Test command-line tool (stc)!• First things to check out!- Test Runner!- Futures API!17!
© 2016 Sencha Inc.Test Runner!
© 2016 Sencha Inc.Test Runner!19!Scenario NameLocal Brower PoolTest FileInventoryMobile DeviceBrowser PoolWebDriverBrowser Pools
© 2016 Sencha Inc.Test Runner!20!Full TestInventory /Run ResultsResult DetailsSelected Browsers
© 2016 Sencha Inc.Test Runner!21!Parking LotAddress• Intelligently managesbrowser tabs!• Parked browsers areredirected to test runners!• Redirected back whenrunner is closed!• Preserves debuggercontext!
© 2016 Sencha Inc.Futures API!
© 2016 Sencha Inc.Make asynchronous tests!simple and reliable!(like synchronous tests)!
© 2016 Sencha Inc.Futures API!• Many (most?) Integration and App tests are asynchronous. They wait on:!- Loading data!- Rendering!- Animations!- Layouts!• Asynchronous tests!- Harder to write!- Harder to maintain!- Sometimes fail sporadically (race conditions)!24!
© 2016 Sencha Inc.A future is an object used to describe a!sequence of actions to take in the future.!
© 2016 Sencha Inc.Futures API – Example!ST.grid('#mygrid'). // locate the gridrowAt(1000). // interact with a rowcell('firstName'). // now with a cellreveal(). // scroll into viewclick(10, 10); // click at offset26!
© 2016 Sencha Inc.Demo!
© 2016 Sencha Inc.Q&A!Don Griffin![email protected]!@dongryphon!http://www.sencha.com!