Automatizando testes de Javascript no Front-end

Presenter Notes

Presenter Notes

Por que testar seu código?

  • corrigir bugs é chato
  • corrigir de novo é mais chato
  • segurança ao subir o código
  • documentação
  • continuous deployment

Presenter Notes

Ferramentas

  • Static code analisys
  • Unit test
  • Coverage
  • Browser tests

Presenter Notes

Validadores

  • JsLint
  • JsHint

    npm install jslint jshint

Presenter Notes

  • validadores são um tipo de static code analisys

Testes unitários e/ou funcionais

  • qUnit
  • YUI Test
  • JSUnit
  • Jasmine
  • Mocha
  • Buster.js
  • etc...

Presenter Notes

  • assinaturas / contratos
  • testes diretos e indiretos

Exemplos

Presenter Notes

Cobertura de código

  • JSCoverage
  • YUITest

Presenter Notes

  • Análise dos testes unitários
  • Detecta quais linhas foram ou não executadas
  • Aponta a falta de testes

Cobertura de código

jscoverage_profile

Presenter Notes

Cobertura de código

jscoverage_profile

Presenter Notes

Browser tests

  • Selenium
  • Cucumber
  • Pyccuracy
  • Zombie
  • Phantom JS

Presenter Notes

Pyccuracy

  • BDD Style
  • Usa o Selenium
  • Fácil de escrever os testes

Presenter Notes

Jenkins

Profile Jenkins

Presenter Notes

Scripts e exemplos

Presenter Notes

Perguntas?

qrcode

Presenter Notes

Referências (1/3)

Reading

  • http://en.wikipedia.org/wiki/Software_testing
  • http://net.tutsplus.com/tutorials/javascript-ajax/how-to-test-your-javascript-code-with-qunit/
  • https://github.com/heynemann/pyccuracy/wiki/
  • https://github.com/guilhermechapiewski/pyccuracy-presentation

Presenter Notes

Referências (2/3)

Tools

  • http://www.jshint.com/
  • http://visionmedia.github.com/mocha/
  • http://yuilibrary.com/projects/yuitest/
  • http://jenkins-ci.org/
  • http://busterjs.org/
  • https://github.com/douglascrockford/JSLint
  • https://github.com/jquery/qunit
  • https://github.com/yui/yuitest

Presenter Notes

Referências (3/3)

Repositories / Projects

  • https://github.com/twada/qunit-tap
  • https://github.com/bitzesty/qunit-mock
  • https://github.com/joshuaclayton/qunit-examples

Presenter Notes