This is a deep dive into the TDD world where you will discover how it helps scale the development process. The talk tackles the business side as well as the technical side of the software development to accommodate all audiences, i.e; Why you should invest in a testing "department" for example, or why you should always take a look at your tests when writing code.
2. • Computer Science graduate from the American University of Beirut.
• Currently freelancing in software engineering and design
• Focused mainly on Mobile Development using best practices and Agile
methods
• Thriving to be an international speaker in different topics
A BRIEF ABOUT ME
Jad Salhani
3. 3
1. Introduction to TDD
2. Why TDD?
3. TDD vs ADD
4. TDD and Agile
5. Live Demo
OUR PROGRAM
4. WHAT IS TDD?
• As the name suggests, the tests drive your development
• When developing a product / feature, first the Test is
designed
• The test will be based on the product spec, and thus will
drive the correct development of the feature
• After the test is written, you keep writing code until it no
longer fails
4
5. For example:
12 class ExampleTest extends TestCase
13 {
14 /**
15 * A basic functional test example.
16 *
17 * @return void
18 */
19 public function testBasicExample()
20 {
21 $this->visit('/')
22 ->see('Laravel');
23 }
24
25 public function testAdditionEquation(){
26 $x = 1;
27 $this->assertEquals(2, $x+$x);
28 }
29 }
6. • A significant advantage of TDD is that it enables you to take
small steps when writing software.
• It is much easier to find, and then fix, defects if you've
written two new lines of code than two thousand
• Especially handy in large-scale projects
• Stable guide for feature development
WHY TDD?
“If it's worth building, it's worth testing.
If it's not worth testing, why are you wasting your time working on it?”
7. TDD VS ADD
• Single Test Suite written at the
beginning (“Acceptance Test”)
• Test Suite covers a large product
specification, not a single feature /
component
• Keep writing code until the test
passes
• Move on to next test / End product
development
“Begin with the end in mind.” — Stephen R. Covey
8. 19 public function testLogin()
20 {
21 $this->assertTrue(true);
22 }
23
24 public function testRegistration()
25 {
26 $this->assertTrue(true);
27 }
28
29 public function testGetItems()
30 {
31 $this->assertTrue(true);
32 }
33
34 public function testPurchaseItem()
35 {
36 $this->assertTrue(true);
37 }
38
39 public function testViewItemDetail()
40 {
41 $this->assertTrue(true);
42 }
• Write all
product tests
from the start
• Keep writing
code until they
pass
ADD EXAMPLE
9. • First write the test for the feature
TDD EXAMPLE
19 public function testLogin()
20 {
21 $this->assertTrue(true);
22 }
• Then write the feature
9 class TestController extends Controller
10 {
11 public function loginUser(){
12 // Some login code in the database
13 }
14 }
• Then run the test
12. AGILE MODEL-DRIVEN
DEVELOPMENT (AMDD)
• AMDD addresses the agile scaling issues that TDD
does not.
• TDD provides detailed specification (tests) whereas
AMDD is better for thinking through bigger issues.
• TDD provides concrete evidence that your
software works whereas AMDD supports your
team, including stakeholders, in working toward a
common understanding.