From 7ec8898c6a3492bffd19408abf907f53f2786075 Mon Sep 17 00:00:00 2001 From: Haiko Schol Date: Tue, 8 Jul 2014 13:14:54 +0200 Subject: [PATCH] add slides for tdd workshop --- .../lets-talk-about-testing/index.html | 200 ++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100755 presentations/lets-talk-about-testing/index.html diff --git a/presentations/lets-talk-about-testing/index.html b/presentations/lets-talk-about-testing/index.html new file mode 100755 index 0000000..3a5559a --- /dev/null +++ b/presentations/lets-talk-about-testing/index.html @@ -0,0 +1,200 @@ + + + + + + OpenTechSchool + + + + + + + + + + + +
+

Let's talk about testing

+

(and then actually do it)

+
+ +
+ +
+
+
+

Let's talk about testing

+

(and then actually do it)

+
+
+
+ +
+
+
+

Automated Testing - What

+
+
    +
  • write programs that test your programs
  • +
  • no really, it makes sense (sometimes)
  • +
+
+
+ +
+
+
+

Automated Testing - Why

+
+
    +
  • everyone writes bugs
  • +
  • manual testing becomes unfeasible quickly
  • +
  • having good tests helps when making changes
  • +
+
+
+ +
+
+
+

Different Kinds of Automated Tests

+
+
    +
  • unit testing
  • +
  • integration testing
  • +
  • system testing
  • +
  • acceptance testing
  • +
+
+
+ +
+
+
+

However...

+
+

Let's not go through each one and try to define them. Wikipedia did that already.

+

Today we focus on unit testing.

+
+
+ +
+
+
+

Unit Testing

+
+
    +
  • very focused tests for a small unit of code
  • +
  • usually a function or a class
  • +
  • most languages have libraries for writing them
  • +
+
+
+ +
+
+
+

Structure of a Unit Test

+
+
    +
  1. arrange
  2. +
  3. act
  4. +
  5. assert
  6. +
+
+
+ +
+
+
+

A Simple Example

+
+
+          
+def add(a, b):
+    return a + b
+
+def test_add():
+    expected = 3               # arrange
+    result = add(1, 2)         # act
+    assert result == expected  # assert
+          
+        
+
+
+ +
+
+
+

Test-Driven Development (TDD)

+
+
    +
  • write the test before you write the code
  • +
  • write only the code required to make the test pass
  • +
  • refactor after each passing test (optional today)
  • +
+
+
+ +
+
+
+

Practising TDD with Code Katas

+
+
    +
  • kata: Japanese for form/pattern
  • +
  • karate students repeat the same kata over and over to perfect their technique
  • +
+
+
+ +
+
+
+

Code Kata

+
+
    +
  • usually time-boxed to 15, 30, 60 minutes
  • +
  • the point is to practise, not to solve the problem
  • +
  • do not try to finish it
  • +
  • when the time is up, delete your code and start over
  • +
+
+
+ +
+
+
+

Time To Hack

+
+ +
+
+ + +
+ +
+ + + + \ No newline at end of file