Javascript orientado a testes

  • 1,024 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,024
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • TODO\n- Subclasse com chamada a A.call(this) no construtor\n\nRequisitos:\n- Ruby\n- RubyGems (ruby setup.rb)\n- JSpec (gem install jspec)\n

Transcript

  • 1. Javascript orientado a testes Alexandre Gomes
  • 2. TDDTDDTDDTDDTDDTDD
  • 3. “ JsUnit is a Unit Testing framework for client-side (in-browser) JavaScript. It is essentially a port of JUnit to JavaScript http://www.jsunit.net/
  • 4. “ Javascript Testing Framework using Rhino. This works similarly to other nUnit testing frameworks, though somewhat customized for javascript. It is exceedingly small, but also surprisingly powerful.http://code.google.com/p/rhinounit/
  • 5. “ JSSpec is a Javascript BDD (Behavior Driven Development) framework.http://code.google.com/p/jsspec/
  • 6. “ A Javascript BDD Framework with nested describes, a convenient assertion syntax, and an intuitive test browser.https://github.com/nkallen/screw-unit
  • 7. “ JSpec is a extremely small, yet very powerful testing framework.http://visionmedia.github.com/jspec/
  • 8. http://pivotal.github.com/jasmine/ http://jsunity.com/https://github.com/drnic/jsunittest http://j3unit.sourceforge.net/
  • 9. $ jspec init helloworldTemplate initialized at `helloworld$ lshelloworld$ cd helloworld/helloworld $helloworld $ lsHistory.md Readme.md lib spechelloworld $ jspec run
  • 10. seu código javascript arquivos que executam o seu código javascript arquivos de teste
  • 11. lib/yourlib.js
  • 12. spec/unit/spec.js
  • 13. helloworld $ jspec run
  • 14. spec/unit/spec.js
  • 15. helloworld $ jspec run
  • 16. helloworld $ jspec run --browsers Firefox
  • 17. helloworld $ jspec run --rhinoPasses: 1 Failures: 0 Duration: 37 msMatematicadeveria somar dois numeros inteiros.helloworld $
  • 18. EXAMPLES: # Run once in default browser jspec run # Run once in Safari and Firefox jspec run --browsers Safari,Firefox # Run once in Opera, Firefox, Chrome, and WebKit jspec run --browsers opera,ff,chrome,webkit # Run custom spec file jspec run foo.html # Auto-run browsers when a file is altered jspec run --bind --browsers Safari,Firefox # Shortcut for the previous example jspec --browsers Safari,Firefox # Run Rhino specs jspec run --rhino # Auto-run rhino when a file is altered jspec --rhino
  • 19. Matchers• be • be_true• eql • be_false• equal • be_type• be_a • be_greater_than• be_an • be_less_than• be_an_instance_of • have• be_at_least • have_at_least• be_at_most • have_at_most• be_within • have_within• be_null • have_length• be_undefined • have_prop• be_empty • have_property
  • 20. P&R