Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

中華電信 教育訓練

待補

  • Login to see the comments

  • Be the first to like this

中華電信 教育訓練

  1. 1. • Why we needTDD • How to startTDD • Conclusion OUTLINE
  2. 2. TDD
  3. 3. • Programmer • •
  4. 4. • DevOps • • •
  5. 5. • Team Leader • Member • Member • • Member
  6. 6. TEST
  7. 7. DeveloperQA
  8. 8. TEST SPEC
  9. 9. /
  10. 10. FAIL Edge of Tomorrow
  11. 11. LEAN & AGILE • • • •
  12. 12. ...
  13. 13. TDD TEST CODE
  14. 14. TDD
  15. 15. XTEST vs OTEST -4 -2 -60
  16. 16. TDD NODEJS
  17. 17. Package
 Library Application Server
  18. 18. LOGIN • 3 step Login
  19. 19. INITIAL
  20. 20. var liftApp = async () => { await models.sequelize.sync({ force: config.connection.force }); await bootstrap(); app.listen(config.port); return app; } if (env !== 'test') liftApp(); module.exports = liftApp import chai from 'chai'; import request from 'supertest'; import sinon from 'sinon'; import liftApp from '../../server'; chai.should(); global.sinon = sinon; before(async (done) => { let app = await liftApp(); global.app = app; global.request = request.agent(app.listen()); done(); }); AP
 start test framework
 start
  21. 21. SPECdescribe('auth login spec', () => { before(async (done) => { let testUser = {'username': 'test', 'password': 'test'} await models.User.create(testUser); done(); }); it('login should be success.', async (done) => { let loginUserFormData = { 'username': ‘test', 'password': ‘test' }; request.post(‘/auth/login') .send(loginUserFormData).expect(200) .end((error, res) => { if (error) done(error); let loginResult = res.body; loginResult.success.should.be.true; done(); }) }
  22. 22. • Mocha test framework • Supertest API • Should or Chai spec
  23. 23. MOCK 
 EX
  24. 24. API OR
  25. 25. • sinon 
 Mock Source code Mock code
  26. 26. Spec SPEC SA/SD 

  27. 27. / SPEC
  28. 28. CI / CD
  29. 29. – “ ”
  30. 30. • • • • • from Clean Code
  31. 31. TDD
  32. 32. THANKS!
  33. 33. • http://qualitycoding.org/tdd-testimonial/ • http://gamesfromwithin.com/backwards-is-forward- making-better-games-with-test-driven-development • http://punnode.com/archives/18016 • http://teddy-chen-tw.blogspot.tw/2014/09/blog- post_22.html

×