Download presentation
Presentation is loading. Please wait.
1
(Test Driven) Software Development
11/16/2018 (Test Driven) Software Development Erik Zeitler
2
Dream up a business case
Think of a service you want to see Figure out how to do it in a way that doesn’t suck Do it Erik Zeitler
3
How to do it? Think about the use cases Cut the work into pieces
How will the service be used Cut the work into pieces User Interface, application code, database Assign pieces within the project group Use Test Driven Development Test each piece (unit tests) Test all pieces together (integration/regression tests) Erik Zeitler
4
Rapid prototyping Make a simple prototype ASAP
See what new ideas it gives you ”Often, users don’t know what they want until they see it” – Steve Jobs Show your prototype to the other project groups Give feedback to each other Erik Zeitler
5
Three-tier architecture
User Interface What should the user see? Make drawings Database What information will you keep? Do data modelling, using ER diagrams Business logic How will you present the data to the users? For any non-trivial function, do test driven development Erik Zeitler
6
Data modelling Keep persistent data in a database
Customer information Banking information Inventory What do you carry, and how much do you have right now? Past activity What has the customer bought? What has the customer looked at? What information do you want to store? Why? Make an Entity Relationship diagram Translate the ER diagram into SQL tables Erik Zeitler
7
Example of an ER diagram
Erik Zeitler
8
Why ER diagrams? ”Keep talking about the algorithms, and everyone will stay totally mystified” ”Show the ER diagram, and everything else will be obvious” Erik Zeitler
9
Software development is all about Getting Things Done
Priorities in software development: Make it work Make it beautiful Make it fast Erik Zeitler
10
How? How to make it work? How to make it beautiful?
First write tests, then write code. This is called Test Driven Development. How to make it beautiful? Re-factor How to make it fast? Don’t worry about performance until performance is a problem. Erik Zeitler
11
Why TDD? Because Because does it A test is a specification
Debugging sucks Testing rocks Because does it A test is a specification The capabilities of a program is defined by its tests If the tests pass we know that the program works – for the test cases. A test is a piece of documentation Erik Zeitler
12
The rules of TDD are simple
You can't write production code unless there is a broken test. First write a test, then write the code When there is a broken test, you change your code to make it pass. When your code is working, you refactor to eliminate any code smells… Erik Zeitler
13
What is code smell? ”Something is fishy about the code”
Examples: Large method A function that is > 1 page Duplicated method A method, function, or procedure that is very similar to another. Contrived Complexity Forced usage of overly complicated design patterns where simpler design would suffice Erik Zeitler
14
Demonstration yay Erik Zeitler
15
A good set of tests Covers all code performs tests on different scale
How many lines of code do you have? How many lines are tested? Do you have > 90% test coverage? performs tests on different scale unit – integration – regression tests for all cases, including edge cases and errors e.g. expectException() Erik Zeitler
16
Different sized tests Large (regression) Medium (integration) Small
(unit) isolation, speed confidence in whole system Erik Zeitler
17
Where is the bug? vs. ”Test failed” ”Test failed” 2018-11-16
Erik Zeitler
18
Does the entire system work?
+ vs. + + + Erik Zeitler
19
Tests for edge cases and errors
Write tests for invalid input data, like empty strings empty data sets false broken input data what happens to your functions if they get ’a%76tr423£4’, when they expected a single character (e.g. ’a’)? Generate exceptions in production code catch exceptions in test code Erik Zeitler
20
Test your database Set up a test database, identical to your production database Grant privileges to your php test script Call your stored procedures from your php test script Validate the result data from the database Erik Zeitler
21
Further resources Soon available on the course home page:
The latest PHPUnit (simpletest) These slides My demonstration examples IDEs (Eclipse, Netbeans, ...) have infrastructure for testing Erik Zeitler
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.