Clean & Quality 

unit tests
Wojtek Zieliński
@codecleaner
What’s it all about?
•  Names matters
•  Exceptions
•  Test Doubles
•  Stubbing Collections
•  Arrange Act Assert
Names matters
Test a single concept
in each test function
Robert C. Martin
Exceptions
Test Doubles
How does getMock() really work?
•  Does Configuration class exist?
•  Create Mock_Configuration_123abc class
extends Configur...
How does getMock() really work?
•  Does Configuration class exist?
•  Create Configuration class
•  Create Mock_Configuration...
Stubs provide canned
answers to calls made
during the test
"Mocks Aren’t Stubs"
Martin Fowler
Mocks are objects
pre-programmed with
expectations which
form a specification
of the calls they are
expected to receive
"Mo...
Stubbing
collections
Arrange
Act
Assert
It’s all about
readability
What’s next?
Questions?
Wojtek Zieliński
@codecleaner
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Clean and Quality Unit Tests
Upcoming SlideShare
Loading in …5
×

Clean and Quality Unit Tests

307 views

Published on

Talk about readability and high quality of unit tests written in PHPUnit

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
307
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Clean and Quality Unit Tests

  1. 1. Clean & Quality unit tests
  2. 2. Wojtek Zieliński @codecleaner
  3. 3. What’s it all about? •  Names matters •  Exceptions •  Test Doubles •  Stubbing Collections •  Arrange Act Assert
  4. 4. Names matters
  5. 5. Test a single concept in each test function Robert C. Martin
  6. 6. Exceptions
  7. 7. Test Doubles
  8. 8. How does getMock() really work? •  Does Configuration class exist? •  Create Mock_Configuration_123abc class extends Configuration class •  Create instance of that class •  Return instance
  9. 9. How does getMock() really work? •  Does Configuration class exist? •  Create Configuration class •  Create Mock_Configuration_123abc class extends Configuration class •  Create instance of that class •  Return instance
  10. 10. Stubs provide canned answers to calls made during the test "Mocks Aren’t Stubs" Martin Fowler
  11. 11. Mocks are objects pre-programmed with expectations which form a specification of the calls they are expected to receive "Mocks Aren’t Stubs" Martin Fowler
  12. 12. Stubbing collections
  13. 13. Arrange Act Assert
  14. 14. It’s all about readability
  15. 15. What’s next?
  16. 16. Questions? Wojtek Zieliński @codecleaner

×