Share
Embed
Testing Best Practices
Talk about testing best practices @colognerb Ruby User Group
elitau
May 16, 2012
Transcript
11 slides
-
PRODUCT QUALITY MEASUREMENT REFERENCE MODEL external quality quality in use
internal quality depends on depends on influences influences User Acceptance Unit tests tests tests Source: ISO/IEC SQuaRE 25000 -
FEEDBACK LOOP Write a failing acceptance test Write a failing
unit test Make the test pass Refactor Source: Growing Object-Oriented Software, Guided by Tests, Steve Freeman and Nat Pryce -
Show payment method in invoice INSIDE-OUT TESTING Show payment method
in invoice mail Show payment method in invoice web view Story Convert story to acceptance criteria Acceptance Criteria Convert acceptance criteria to acceptance tests describe "Subscribe and pay for Premium" it "should show payment method in invoice mail" do subscribe_to_premium_and_pay(user, :pay_with => "Visa") current_email.should have_body_text("Visa") end it "should show payment method in invoice web view" visit invoice_path page.should have_content("Visa") end end Acceptance Tests Unit Tests Create unit tests where appropriate describe "Invoice" it "should have payment method" do user = stub("User") subscription = stub("Subscription") invoice = create_invoice(user, subscription, :pay_with => "Visa") invoice.payment_method.should == "Visa" end end -
NAMING CONVENTIONS • Acceptance Testing: Formal testing with respect to
user needs, requirements, and business processes [...] to determine whether or not to accept the system. [After IEEE 610] • Integration Testing: Testing performed to expose defects in the interfaces and in the interactions between integrated components or systems. • Unit Test: The testing of individual software components. [After IEEE 610] Source: International Software Testing Qualifications Board, Glossary of Testing Terms, www.istqb.org -
ACCEPTANCE TEST • Blackbox: In a web app, request and
response is all we have • Test common use cases without getting to low level in your assertions • No mocks or stubs • Test invokes entire stack including web framework, databases, caches, etc. -
UNIT TEST • Whitebox: Control and see everything • Used
primarily as a helper for the developer (to drive the design of SUT) • Used in bugfixes to simulate the bug and afterwards as a regression test • Mock and stub collaborators of SUT -
DEFAULT RAILS TEST FOLDER STRUCTURE • functional • integration •
performance • unit • acceptance • performance • unit • models • controllers • views -
SOURCES • Growing Object-Oriented Software, Guided by Tests - Steve
Freeman and Nat Pryce • ISO/IEC 25010 SQuaRE (successor to ISO 9126)