Presentation part of the workshop about Quality Assurance, which happened at ThoughtWorks Kampala in October of 2013.
This presentation gives an overview around Agile Test Practices, including TDD, BDD, as well as the test automation pyramid.
3. 3
Why do we test?
Testing should be integrated with one of the
quality assurance activities
This verification is done to ensure that we are
building the system right
4. 4
Types of testing
Unit Testing
Integration Testing
Functional Testing
System Testing
Load Testing
Performance Testing
Acceptance Testing
7. 7
Unit Test
“Unit Test is a procedure used to validate that
individual units of functional code are working
properly.
Is usually done by developers
Improves quality
Facilitates changes (refactoring)
Enables automation
Simplifies integration
8. 8
What is TDD
“TDD is an evolutionary approach to development which
instructs you to have test-first development intent. “
Small successful, tested steps.
Do the simplest thing that could possibly work.
10. 10
JUnit
A open source regression testing framework
Used by developers to implement unit tests in Java
Provides tools for:
-assertions
-running tests
-aggregating tests (suites)
11. 11
Sample Code
public class Foo {
public Foo() {
}
public String helloWorld() {
return "Hello World";
}
public boolean truth() {
return true;
}
}
12. 12
How to test it?
Debugger
-Needs human intervention, slow, boring
Print Statements
-Needs human intervention, slow, polluted code, "Scroll
Blindness”
JUnit
-Automatic,quick,no code pollution
13. 13
Sample JUnit Code
public class FooTest extends TestCase {
private Foo foo= new Foo();
public void testHelloWorld() {
assertEquals("Hello World", foo.helloWorld());
}
public void testTruth() {
assertTrue(foo.truth());
}
}
22. 22
Given
Tells us the prerequisites (what needs to be
setup / done before we start this test?)
Setup phase of automated testing
23. 23
When
Tells us the action that needs to happen in order
to trigger the outcomes that we are
Testing for - this will be the action that the test
needs to perform
24. 24
Then
Tells us what to expect when the action is
performed - this is the validation step of the
automated test
26. 26
How we use BDD?
Given the account has a balance of UGX 100,000
When the customer requests for UGX 50,000
Then the account is debited by UGX 50,000
27. 27
How we use BDD?
Given the machine contains cash
When the customer requests cash
Then ensure the customer’s account is debited
And ensure cash is returned
And ensure the card is returned
28. 28
How we use BDD?
New expected functionality:
Customer should be able to withdraw money
from his account only if his card is valid.
29. 29
How we use BDD?
Given the card is valid
And the machine contains cash
When the customer requests cash
Then ensure the customer’s account is debited
And ensure cash is returned
And ensure the card is returned
30. 30
How can I assess the
scenarios that I write?
Capturing the expected behavior?
Readable and clear enough for a human?
Testable?
Driving the developers down a particular
implementation route?
Using “strong verbs” to describe each step?
Allowing automation on “WHEN” statement?
Telling a story?
Are my scenarios:
31. 31
Scenario: Searching for an item on Amazon
Given I’m at Amazon’s homepage
When I search for “Electronics” on the search dropdown
on the top of the page
Then I can see the results of my search
32. 32
What’s wrong?
Contains User Interface (UI) language (dialogs,
selecting, clicking)
The scenario language contains details that only an
experienced user of Amazon customer can follow it
“Weak” verbs – can…
37. 37
Want to know more?
The Rspec book – David Chelimsky
Bridging the Communication Gap – Gojko Adzic
Specification by Example - Gojko Adzic
The Cucumber Book – Matt Whynne/Aslak Hellsay