salary’, function(t) { var user = new My.model.User({ Salary : 5000 }); t.expect(user.getAnnualSalary()).toBe(60000); }); t.it(‘Should treat incomplete name as invalid’, function(t) { var user = new My.model.User({ FirstName : ‘Bob’ }); t.expect(user.isValid()).toBeFalsy(); }); }) User.t.js Saturday, July 20, 13
var user = new My.model.User({ FirstName : ‘Bob’ }); t.expect(user.get(‘FirstName’)).toBe(‘Bob’); }); }) Don’t test the framework Saturday, July 20, 13
classes • Test your components in isolation: - My.app.UserList - My.app.OrderForm Test your public config properties + API Sanity tests give you peace of mind Saturday, July 20, 13
user • Hard to solve using tools that focus on raw DOM/HTML. • Siesta allows you to simulate user interactions: - type - click - drag Saturday, July 20, 13
unsafe - Having 100% code coverage not really realistic - 100% code coverage !== working code - Absense of code coverage is the main interest Saturday, July 20, 13
level. • Test your Model layer first, great ROI. • Code coverage helps you find untested code in your app. 100% test coverage !== working app. • Automated functional testing saves time and $$$ Saturday, July 20, 13