代写代考 AA-251870-19-2.pdf Page 10 https://marquetteeducator.wordpress.com/2012/07/

Introduction to Testing
Sue Inn Chng
The University of 1
Image Credit: https://www.bbc.com/news/world-asia-china-33059635

Copyright By PowCoder代写 加微信 powcoder

Life is full of tests!
– Everyone would have undergone some form of testing by now. Examples:
– NationalAssessmentProgram–LiteracyandNumeracy(NAPLAN) – HighSchoolCertificate(HSC)
– Healthexamination
– What is a test?
– Do a Google search and read definitions.
– Which one is most applicable for our unit’s context?
The University of 2

Test Example – Preschool Testing
– Goal: Identify colours. Which colour is Red?
Pointed to Red
Did not point to Red.
Object of Test
Image Credit: https://www.tests.com/practice/pre-school-admissions-practice-test The University of 3

Test Example – Medical Testing
– Goal: Detect a condition and diagnose patient’s illness.
Not COVID
Nasal and throat swab for COVID
Object of Test
Image Credit: https://www.tests.com/practice/pre-school-admissions-practice-test The University of 4

Test Example – Software Testing
– Goal: Software is working as it should be working e.g. produces correct output (response) given inputs.
– Example: Write a program that adds two numbers.
The University of 5
Object of Test

Reality of Testing your Program
– My Testing Practice survey. – Testingfrustration:
– Idon’tknowwhat’swrongwithit on Ed. It works on my device.
– Itworksfortheexamplesgiven, why won’t the hidden test cases pass?!!
– Whydoesn’titpasstestX?!!
– Whydoesn’tmyprogram round correctly?!!
– Endinground() confusion. The University of 6

Test Driven Development (TDD)
– This is a way of software development that requires you to write the tests for a given function first, before you even write the function!
– It makes you think exactly what you want your function(s) to do in terms of:
– Whatthenormalfunctionalityshouldbe?
– What should happen given “bad” input (e.g. passing a negative number to a function that expects positive numbers).
– Should test whether you are on the right track throughout development and not only at the end.
The University of 7

General Testing Process
– Determine goal. [Purpose of the test]
– Designteststomeasuregoal.[Writetestcases]
– Apply tests on test object to measure achievement of goal. [Implement and run test cases]
– Evaluate test outcome. [Check outcome and determine action]
The University of 8

W8: Testing
– Part A: Introduction to testing – TypesofTests
– Writingtestcases
– Part B: Tools for testing – assert and functions
– unittest module
– doctest module
The University of 9

Purpose of Testing
– Highlydependentonwhatyouwantto assess about your system.
– Systemscanbemadeupofmultiple modules (parts).
– Furnitureeasilyassemblefromseparate parts if well-designed.
– Softwareeasilyassemblefromseparate functions (and classes) if well-designed.
– Differenttypeoftestsanditscontents (input-expected outputs) will give you different information about your system.
Image credit:
The University of Sydney https://www.ikea.com/au/en/assembly_instructions/markus-office-chair-vissle-dark-grey__AA-251870-19-2.pdf Page 10 https://marquetteeducator.wordpress.com/2012/07/12/climbthattree/

The Ikea Chair
The University of 11

teamX_1.py
teamX_2.py
The University of 12
Final Product

Types of Tests: The Testing Pyramid
– End-to-end Tests
– Full functionality of system.
– Integration Tests
– Examines how different components of a system interact with one another.
– Unit Tests
– Fast and simple tests that target the smallest possible components of a system.
The University of 13

The Ikea Chair – Testing
How do you perform each type of testing on an Ikea Chair?
• End-to-end testing
• Integration testing
• Unit testing
For each test, state the component that is being tested and its expected behaviour/dimensions.
The University of 14

The Ikea Chair – Testing
Which are examples of integration testing and unit testing? Hint: Check the component that is being tested!
• All wheels are the same size e.g. 10cm diameter?
• Wheels movement is smooth when rolled on surface?
• Correct size to allow attachment between wheel and spoke? • Each opening is the same size?
• Wheel stays attached to each spoke when frame is lifted? • All wheels move in the correct direction during frame
• Does each piston move correctly? • Diameter of piston is correct size?
• Piston stays attached when frame and piston is lifted? • Piston movement is correct after attachment to frame?
The University of 15

Exercise: Testing a Door!
– Identify components that make up a door.
– For each type of test in the Testing Pyramid, describe:
– Test object:
Door Frame
• Whichcomponent(s)is/are being tested (subjected to the test)?
– Test case:
The University of 16
Whatareyoumeasuring?
How do you know it pass/fail the test?
Door Panel

Exercise: Testing a Door!
Types of Test
End-to-end
Integration
Purpose of testing
Functionality of door.
Components work together correctly
Components are without defects and functions.
Test object
Example Test Cases
The University of 17

Writing tests
– Known as test case design
– Positive case:
– System response under normal operating parameters (when valid inputs are given).
– Negative case:
– System response to invalid inputs.
– Will‘break’theprogramifnothandled appropriately.
– Edge case:
– Extreme cases e.g. load on a bridge is maximum.
Source: iihs.org
– Corner case:
– More than one dimension is at an extreme e.g. bridge is maximum load AND hit with winds AND earthquake.
The University of 19

Testing – is_even() function
– Functiontocheckifagivennumberiseven.
– ReturnsTrueifnumberiseven.Otherwise,False.
– Determine the type of test case and expected output for each of the following inputs.
Type of case
Expected Output
is_even(5)
is_even(2)
is_even(5.5)
is_even(“HELLO”)
is_even([])
is_even(-999999999999999999999)
The University of 20

Practice: Testing – search function
– Searchfunctionwithtwoarguments:searchobjectandan iterable object.
– Returnscountofoccurrencesandindexlocations.
Type of case
Expected Output
hunt(0, “510451025”)
hunt(“5”, “510451025”)
hunt(“Bob”, [])
hunt(1, 110)
hunt((1, 10), (1, 10, 20, 30, 40))
hunt(5, 5.5)
The University of 21

– Testdrivendevelopment(TDD)styleofdevelopmentfocuson testing your application to ensure that it delivers the features and functionalities that you set out to create.
– Testingpyramid:end-to-endtests,integrationtestsandunittest
– Tests in real life for everyday objects:
– Relationshipbetweentypeoftest,itspurpose,focusoftestingand coming up with example test cases.
– Outcome:Adraftofyourtestplan!
– Writingtests:Thinkingaboutpositive,negative,edgecases
The University of 22

Reading This Week
– Chapter6.Testing.Kernighan,&Pike,R.(1999).Thepractice of programming. Addison-Wesley.
The University of 23

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com