1.Lecture 1
1.Lecture 1
Course Overview
Software Engineering
Software Quality Assurance
Test Driven Development
Lecturer contact
COURSE OVERVIEW
Course Objectives
• Learn & apply software engineering process
• Understand software quality
• Deliver a well-documented software product
• Learn techniques to measure, ensure and
improve software quality
• Learn software testing
• Learn test-driven software development
Why study SQA?
• To create better software products.
• To become a better software engineer.
• To be able to join professional software
development teams.
• People's lives are affected by quality of the
software they use.
Why software engineering?
• Software is an essential part of our modern
world.
• There are increasing demands for large, complex
software products.
• Individual programmers are unable to develop
software systems…
– In large-scale
– With high quality
– On time
– Within budget
What is software failure?
• Does not satisfy customer's needs
• Contains (hard-to-spot) bugs
• Late delivery (or not at all), overbudget
• Caused by:
– Complex, changing requirements
– Limited budget, time, human resources
– The lack of quality assurance
Examples of software failure
• Smartphone apps not functioning correctly
and drains battery fast
• Course website ocasionally inaccessible
• Software-controlled car brake sometimes not
working
• Internet banking system calculates money
transactions incorrectly
Consequences of software failure
• Money is lost
• People's lives are endangered
• Business operations are interrupted
Main activities of software engineering
1. Software specification
Customers and engineers define
the software to be produced and
the constraints on its operation.
2. Software development
The software is designed and
programmed.
Main activities of software engineering
3. Software validation
The software is checked to ensure
that it is what the customer
requires.
4. Software evolution
The software is modified to reflect
changing customer and market
requirements.
Software Process
A software process is a set of related activities that
leads to the production of a software product.
(Ian Sommerville, 2011)
TEST-DRIVEN DEVELOPMENT
TEST-DRIVEN DEVELOPMENT
TEST-DRIVEN DEVELOPMENT
Test-Driven Development
• Originated from Extreme Programming (XP)
– XP is a software engineering methodology
– The author of TDD is Kent Beck
• Basic principle: test first
– Programmer should also be tester
– If you can't test, you shouldn't code
• Coding is done in small iterations
– The program builds up little-by-little
TDD iteration
1. Write a Test for a feature
– Quickly make the test compile
– Run the test to see it returns FAILED
2. Write necessary code to make the test PASS
– As fast as possible
– No need to be real code or good code
3. Refactor the code
– All tests must still PASS
– Remove bad, duplicated codes
– Apply (good) code conventions
TDD benefits
• Instant feedback
• More confidence on the resulting program
• Better development practices
– Well organized code
– Less bugs
JUnit
• The basic idea:
– For a given class Foo, create another class
FooTest to test it.
– The FooTest class contains various methods,
each of which is a test case.
– The tester writes some assertion statements in
the test case method's body.
– The test case returns PASS if all assertions return
True and FAILED otherwise.
JUnit
• Example of a JUnit test class:
TDD Example
• Writing the Circle program.
– Create Circle objects.
– Calculate Area, Diameter.
– Increase, decrease Radius.
Step 1a – Write a Test
Step 1b – Make the Test compile
• Create the Circle class.
• Write a constructor.
• Write the getRadius() method that
returns any number (say, 0).
Step 1c – Run the Test
• Just to see that it FAILED
Step 2a – Write code
• Just enough to make it PASS
Step 2b – Run the Test again
• Just to see that it PASS
Step 3a – Remove bad, duplicated codes