software testing anti-patterns - code pipes · title: microsoft powerpoint - software testing...
TRANSCRIPT
![Page 1: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/1.jpg)
Software testing anti-patterns
Make ITOctober 2019
Kostis Kapelonis
1
![Page 2: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/2.jpg)
Antipattern – common mistake
2
![Page 3: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/3.jpg)
Things I love
Testing Automation
3
![Page 4: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/4.jpg)
Things I write
4
![Page 5: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/5.jpg)
Things I blog
http://blog.codepipes.com/testing/software-testing-antipatterns.html
5
![Page 6: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/6.jpg)
Things I blog
https://news.ycombinator.com/item?id=16894927 6
![Page 7: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/7.jpg)
Current Work
Docker based CI/CD solution for Helm/ solution for Helm/ Kubernetesdeployments
7
![Page 8: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/8.jpg)
Current Work
8
![Page 9: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/9.jpg)
Current Work
9
![Page 10: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/10.jpg)
Current Work
https://codefresh.io/blog/
https://codefresh.io/features/
10
![Page 11: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/11.jpg)
Testing pyramid
11
![Page 12: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/12.jpg)
Some definitions
12
![Page 13: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/13.jpg)
Unit tests
• Require ONLY source code• Everything that is external is mocked• Mainly involve business logic testing• Focus is on a single method/class• Focus is on a single method/class• Run with xUnit or similar framework• Easy to setup and run• Fast (20- 500ms)
13
![Page 14: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/14.jpg)
Unit test example
Basket basket = new Basket()basket.add(“Samsung 4k TV”, 600)basket.add(“Sony PS4”, 300)
basket.getValue() == 900
14
![Page 15: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/15.jpg)
Integration/Service/Component test
• Uses a database• Uses the network to call another component• Uses a queue/webservice• Reads/writes files, performs I/O• Reads/writes files, performs I/O• Needs the application to be deployed (even
partially)• Can be complex to setup and run• Slow (seconds or even minutes)
15
![Page 16: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/16.jpg)
Integration test example
Basket basket = new Basket(….)Customer customer = new Customer(…)customer.checkout(basket, cc, inventory)
Assert invoices, cc charge, inventory subtraction etc.
16
![Page 17: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/17.jpg)
Maven lifecycle
17
![Page 18: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/18.jpg)
Antipattern 1 – Only unit tests
18
![Page 19: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/19.jpg)
Antipattern 1 – Only unit tests
• Usually in small companies• Developers who have never seen integration
tests• Integration tests were abandoned• Integration tests were abandoned• Test Environment is “hard” to setup
19
![Page 20: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/20.jpg)
We need integration tests
20
![Page 21: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/21.jpg)
Antipattern 1 – Solution
• Dockerize your application• Launch containers after every Pull Request• Test features BEFORE merging to master• Anybody should be able to launch all or part • Anybody should be able to launch all or part
of the application with a single command
21
![Page 22: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/22.jpg)
Antipattern 2 – Only integration tests
22
![Page 23: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/23.jpg)
Antipattern 2 – Only integration tests
• Usually found in big companies• “Unit tests are a waste of time”• People were forced to write unit tests for code
coverage requirementscoverage requirements• “Unit tests are useless, they never fail”• “Value comes only from integration tests”
23
![Page 24: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/24.jpg)
We need unit tests
1. Integration tests are complex2. Integration tests are slow3. Integration test are hard to setup and debug
24
![Page 25: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/25.jpg)
Integration tests are complex
25
![Page 26: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/26.jpg)
Let’s test a service
26
![Page 27: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/27.jpg)
Let’s test a service
• A Java service• 4 methods• CC = cyclomatic complexity (number of code
paths)paths)
27
![Page 28: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/28.jpg)
Only unit tests
• Can write 2 + 5 + 3 + 2 = 12 unit tests• Get 100% of business logic• The full application has other more services
28
![Page 29: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/29.jpg)
Only integration tests
• Should write 2 * 5 * 3 * 2 = 60 tests• People cheat and only choose some
“representative tests”• Usually happy path scenarios• Usually happy path scenarios
29
![Page 30: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/30.jpg)
Hard to test corner cases
• A special scenario in C requires….• A special scenario in B that requires…• A special scenario in A
30
![Page 31: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/31.jpg)
Easy to test corner cases
• With unit tests only a single method is focused• Corner case can be created on the spot• Very easy to test
31
![Page 32: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/32.jpg)
Integration tests are slow
32
![Page 33: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/33.jpg)
Integration tests are slow
• Two developers Mary and Joe• Joe writes only integration tests• Mary writes unit tests PLUS some integration
teststests
33
![Page 34: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/34.jpg)
Test assumptions
• Each unit test takes 60ms (on average)• Each integration test takes 800ms (on average)• The application has 40 services like the one
shown in the previous sectionshown in the previous section• Mary is writing 10 unit tests and 2 integration
tests for each service• Joe is writing 12 integration tests for each
service
34
![Page 35: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/35.jpg)
Speed comparison
• Joe waits 6 minutes after a commit• Mary waits 1 minute
35
![Page 36: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/36.jpg)
Integration tests are hard to debug
36
![Page 37: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/37.jpg)
E-Shop application
• You write tests for the typical eshopapplications
• Customers buy products• Discounts on prices• Discounts on prices• Warehouse inventory• Credit card processing
37
![Page 38: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/38.jpg)
Result from integration tests
38
![Page 39: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/39.jpg)
Result from all tests
39
![Page 40: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/40.jpg)
Anti-pattern 2 - summary
1. Integration tests are complex2. Integration tests are slow3. Integration test are hard to setup and debug
40
![Page 41: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/41.jpg)
Corollary
• We need both unit and integration tests
• Having only one type is an anti-• Having only one type is an anti-pattern
41
![Page 42: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/42.jpg)
Antipattern 3 – Wrong kinds of tests
42
![Page 43: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/43.jpg)
Amount of tests for each type
• Test pyramid is only a suggestion• You need to decide what your application is
doing• Different applications have different needs• Different applications have different needs
43
![Page 44: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/44.jpg)
Example 1
44
![Page 45: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/45.jpg)
Example 2
45
![Page 46: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/46.jpg)
Example 3
46
![Page 47: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/47.jpg)
Antipattern 4 – Testing the wrong functionality
47
![Page 48: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/48.jpg)
Code != file folders
48
![Page 49: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/49.jpg)
Deployment time
49
![Page 50: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/50.jpg)
Two bugs after deployment
1. Customers cannot check-out their cart halting all sales
2. Customers get wrong recommendations when they browse products.when they browse products.
Obviously first one is critical, second one is not
50
![Page 51: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/51.jpg)
Code severity
Critical code - This is the code that breaks often, gets most of new features and has a big impact on application users
51
![Page 52: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/52.jpg)
Code severity
Core code - This is the code that breaks sometimes, gets few new features and has medium impact on the application users
52
![Page 53: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/53.jpg)
Code severity
Other code - This is code that rarely changes, rarely gets new features and has minimal impact on application users.
53
![Page 54: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/54.jpg)
Write tests for code that
• Breaks often• Changes often• Is critical to the business
54
![Page 55: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/55.jpg)
Antipattern 5 – Testing internal implementation
55
![Page 56: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/56.jpg)
Antipattern 5 – Testing internal implementation
• Worse kind of tests• Wasted time the first time they are written• Wasted time when a new feature is added• They give a bad name to unit testing• They give a bad name to unit testing• Closely connected to antipattern 2 (no unit
tests)• Mostly relevant for unit tests
56
![Page 57: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/57.jpg)
Rules of unit testing
57
![Page 58: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/58.jpg)
1. Test behavior and not state
58
![Page 59: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/59.jpg)
2. Test behavior and not state
59
![Page 60: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/60.jpg)
3. If this is your first unit test
…test behavior and not state!
60
![Page 61: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/61.jpg)
Testing state – bad Example
61
![Page 62: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/62.jpg)
Testing state – bad Example
• Customer type 0 means “guest” and 1 means “registered user”
• 10 unit tests are written that verify this particular fieldparticular field
62
![Page 63: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/63.jpg)
Testing state – bad Example
• Customer type 2 means “affiliate” and 3 means “premium user”
• 20 more unit tests are written that verify this particular fieldparticular field
63
![Page 64: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/64.jpg)
Testing state – bad Example
40 tests in total, all looking at this field
64
![Page 65: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/65.jpg)
New feature from customers
65
![Page 66: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/66.jpg)
New feature from customers
1. For registered users, their email should also be stored
2. For affiliate users, their company should also be storedbe stored
3. Premium users can now gather reward points.
66
![Page 67: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/67.jpg)
40 tests are now broken
67
![Page 68: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/68.jpg)
40 tests are now broken
• This is why some people hate unit tests• “I try to implement a feature and all tests are
broken”• “I spend more time with tests than actual • “I spend more time with tests than actual
code”• Damage is already done
68
![Page 69: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/69.jpg)
Testing behavior instead of state
69
![Page 70: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/70.jpg)
Testing behavior instead of state
• Business needs do not affect tests• At most 10 tests will break (not all of them)• New fields can be added/removed in
customer objectcustomer object
70
![Page 71: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/71.jpg)
Good names of Test Methods
• guestUsersDoNotGetRewardPoints()• premiumCustomerShouldGetDiscount()• maximum100AwardPointPerBasket()• customerWithoutEmailDoesNotGetNewsletter()• customerWithoutEmailDoesNotGetNewsletter()• digitalGoodsNeverHaveWeight()• orderHistoryAlwaysIncludesShippingAddress()
71
![Page 72: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/72.jpg)
Bad names of Test Methods
• checkInvoiceType()• billingTest1()• billingTest2()• testJIRA2345()• testJIRA2345()• customerObjectHasCorrectFieldsTest()• productsTypeCshouldBelongToCategoryA()
72
![Page 73: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/73.jpg)
Antipattern 6 – Paying too much attention to code coverage
73
![Page 74: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/74.jpg)
Code coverage is a trap
74
![Page 75: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/75.jpg)
How much code coverage is enough?
75
![Page 76: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/76.jpg)
Code coverage everywhere
• It is easy to understand• It is easy to measure• There are many tools for measuring it• Also familiar to other project stakeholders• Also familiar to other project stakeholders• Beloved by QA departments and managers
76
![Page 77: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/77.jpg)
I will tell you a secret
77
![Page 78: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/78.jpg)
I will tell you a secret
A project can be full of bugs and A project can be full of bugs and still have 100% code coverage
78
![Page 79: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/79.jpg)
Sample application
79
![Page 80: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/80.jpg)
100% Coverage
80
![Page 81: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/81.jpg)
Bug if direction is double the angle
81
![Page 82: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/82.jpg)
I will tell you a secret
Do not try to achieve a specific Do not try to achieve a specific number (such as 100%)
82
![Page 83: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/83.jpg)
I will tell you a secret
Bigger numbers require more Bigger numbers require more effort (logarithmic?)
83
![Page 84: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/84.jpg)
I will tell you a secret
Getting from 80% to 100% is Getting from 80% to 100% is much more difficult than 0% to 20%
84
![Page 85: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/85.jpg)
I will tell you a secret
85
![Page 86: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/86.jpg)
I will tell you a secret
Increasing code coverage has Increasing code coverage has diminishing returns
86
![Page 87: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/87.jpg)
I will tell you a secret
87
![Page 88: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/88.jpg)
I will tell you a secret
High code coverage !=High code coverage !=high code quality
88
![Page 89: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/89.jpg)
Give me a number!
89
![Page 90: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/90.jpg)
Best code coverage
20% is the magic 20% is the magic number
90
![Page 91: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/91.jpg)
Pareto principle
20% of your code is responsible for 80% of your bugsbugs
91
![Page 92: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/92.jpg)
Pareto principle
92
![Page 93: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/93.jpg)
Pareto principle
Try to achieve 100% coverage of your CRITICAL code, (which itself is probably 20% of total itself is probably 20% of total code)
93
![Page 94: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/94.jpg)
Antipattern 7 – Flaky or slow tests
94
![Page 95: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/95.jpg)
Antipattern 7 – Flaky or slow tests
• Flaky tests are a well known problem• They hide real bugs• They make tests untrustworthy• People start ignoring tests• People start ignoring tests• Everything goes downhill afterwards
95
![Page 96: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/96.jpg)
Antipattern 7 – Flaky or slow tests
96
![Page 97: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/97.jpg)
Antipattern 7 – Flaky or slow tests
• As we go up in pyramid tests become slow/flaky
• UI tests are notoriously problematic• Test environments parity• Test environments parity
97
![Page 98: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/98.jpg)
Antipattern 7 – Solution
• Fix flaky tests• Isolate them in a different test suite• Tests should be rock solid• Failure of test means immediate problem with • Failure of test means immediate problem with
code• Exclude tests that are broken for a temporary
reason
98
![Page 99: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/99.jpg)
Antipattern 8 – Running tests manually
99
![Page 100: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/100.jpg)
Quiz:
How many steps do you need to setup and run your whole test suite?
100
![Page 101: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/101.jpg)
Wrong answers
1. Prepare database2. Edit settings file3. Prepare test environment4. Run tests4. Run tests5. Cleanup environment
101
![Page 102: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/102.jpg)
Correct answer
• Before commit: single command to run tests• After commit: Tests run automatically, with
no human intervention
102
![Page 103: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/103.jpg)
Correct answer
103
![Page 104: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/104.jpg)
Quiz:
What is the role of the test engineer?What is the role of the QA department?
104
![Page 105: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/105.jpg)
Test engineers
• Test engineers should NOT run tests• Test engineers should write NEW tests and
add them in the automatic test suite• QA department should NOT run tests• QA department should NOT run tests• QA department should only evaluate results
from automatic test suites• CI server actually runs 99% of tests• 1% of smoke GUI tests run manually
105
![Page 106: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/106.jpg)
Testing strategy
106
![Page 107: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/107.jpg)
Antipattern 8 – Solution
• Automate everything• Make local testing easy for developers• CI server should run test for each feature
branch in a transparent mannerbranch in a transparent manner• You should also have
smoke/acceptance/production tests
107
![Page 108: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/108.jpg)
Antipattern 9 – Not respecting test code
108
![Page 109: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/109.jpg)
Antipattern 9 – Not respecting test code
• Developers pay great attention to main code• They treat test code as second class citizen• Test code is hacky and does not follow DRY,
SOLID and KISS principlesSOLID and KISS principles
109
![Page 110: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/110.jpg)
I will tell you a secret
110
![Page 111: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/111.jpg)
I will tell you a secret
Test code is as important as Test code is as important as feature code
111
![Page 112: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/112.jpg)
Antipattern 9 – Solution
• Create common abstractions for test data creation
• Centralize common assert code• Refactor test code when needed• Refactor test code when needed• Apply KISS, SOLID and DRY to test code• Do not leave tech debt in test code
112
![Page 113: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/113.jpg)
Antipattern 10 – Not converting production bugs to tests
113
![Page 114: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/114.jpg)
Quiz:
You start working on an unknown project with zero tests. Where do you start testing?
114
![Page 115: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/115.jpg)
Write test for code that
• Breaks often• Changes often• Is critical to the business
115
![Page 116: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/116.jpg)
How do you find critical code
See what bugs appear in See what bugs appear in production
116
![Page 117: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/117.jpg)
How do you find critical code
…and write unit/integration …and write unit/integration tests for them
117
![Page 118: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/118.jpg)
Production bugs
• Have passed all QA gates (since they appeared in production already)
• Are great for regression testing
118
![Page 119: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/119.jpg)
Production bugs
Should only happen once!Should only happen once!
119
![Page 120: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/120.jpg)
New project – zero tests
• Do NOT start testing code you understand• Do NOT start testing code that requires easy
tests• Do NOT start testing the first folder in your file • Do NOT start testing the first folder in your file
system• Do NOT start testing what a colleague
suggested
120
![Page 121: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/121.jpg)
New project – zero tests
First test suite should be First test suite should be production bugs
121
![Page 122: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/122.jpg)
Antipattern 11 – TDD madness
122
![Page 123: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/123.jpg)
Antipattern 11 – TDD madness
• Test driven development says that tests are written before code
• Add test, run test, refactor, repeat
123
![Page 124: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/124.jpg)
I will tell you a secret
124
![Page 125: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/125.jpg)
You can write tests
• Before the feature implementation• During the feature implementation• After the feature implementation• Never (see “Other” code severity)• Never (see “Other” code severity)
125
![Page 126: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/126.jpg)
TDD requires a spec
If you have no spec TDD is a If you have no spec TDD is a waste of time
126
![Page 127: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/127.jpg)
TDD is not needed
• For research code• For throw away code• For quick spikes/POCs• For weekend projects• For weekend projects• For startups that pivot all the time
127
![Page 128: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/128.jpg)
Antipattern 12 – Not reading test framework documentation
128
![Page 129: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/129.jpg)
A professional is..
…somebody who knows the …somebody who knows the tools of the trade
129
![Page 130: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/130.jpg)
Antipattern 12 – Not reading test documentation
• Do not re-invent the wheel• Do not write new test utilities• Do not create “smart” test solutions• Do not copy paste test code• Do not copy paste test code• Do not write “helper” test methods• Do not ignore off-the-self test libraries
130
![Page 131: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/131.jpg)
Research and learn
Your test framework and its Your test framework and its capabilities
131
![Page 132: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/132.jpg)
Learn about
• Parameterized tests• Mocks and stubs (and spies)• Test setup and tear down• Test categorization• Test categorization• Conditional running for tests• Assertion grouping
132
![Page 133: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/133.jpg)
Learn about
• Test data creators• Http client libraries• HTTP mock libraries• Mutation/fuzzy testing• Mutation/fuzzy testing• Db cleanup/rollback• Load testing
133
![Page 134: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/134.jpg)
Assume that your “smart” solution
…is already invented and …is already invented and available on the internet
134
![Page 135: Software testing anti-patterns - Code Pipes · Title: Microsoft PowerPoint - Software testing anti-patterns.pptx Author: Kostis Created Date: 10/13/2019 8:49:59 PM](https://reader034.vdocuments.net/reader034/viewer/2022050522/5fa538ab2418a329276f9fd6/html5/thumbnails/135.jpg)
The end
http://blog.codepipes.com/testing/software-testing-antipatterns.html
135