Lecture10 2
Lecture10 2
ENGG1810/9810
Introduction to Engineering Computing
Week 10: Application II
COMMONWEALTH OF AUSTRALIA
WARNING
The material in this communication may be subject to copyright under the Act.
Any further reproduction or communication of this material by you may be the
subject of copyright protection under the Act.
ft
Week 5: Functions I
f
Week 6: Functions II Functions
Week 7: Libraries and Modules I
and Packages
Week 9: Application I
Today’s Lecture
• LabTest 2 Guide
• Assessment Details
• Question Types and Sample Questions
• Testing Your Code
• Manual Testing
• Automatic Testing
• Python unittest
• TestCase
• Assertion
• Check the process time
ENGG1810/9810
LabTest 2 Guideline
We will go through the Lab Test 2 Guideline and sample Qs during the Lecture
Please join the lecture and ask Questions
ENGG1810/9810
Today’s Lecture
• LabTest 2 Guide
• Assessment Details
• Sample Questions
• Testing Your Code
• Manual Testing
• Automatic Testing
• Python unittest
• TestCase
• Assertion
• Check the process time
ENGG1810/9810
How??
ENGG1810/9810
Class ShoppingCart
a to b 2 C
aname for each object
Imig
a atb
Add a new item then
to the list a t C B
Calculate the
total cost
g
ENGG1810/9810
Class ShoppingCart
Calculate the
total cost
ENGG1810/9810
Class ShoppingCart
Class ShoppingCart
With Script
Importing
createdinstant avec fruition
nothing
added
3addingitems
Milk 2x5
1 7
yogurt
D
ENGG1810/9810
Class ShoppingCart
Today’s Lecture
• LabTest 2 Guide
• Assessment Details
• Sample Questions
• Testing Your Code
• Manual Testing
• Automatic Testing
• Python unittest
• TestCase
• Assertion
• Check the process time
ENGG1810/9810
Automated Testing
Today’s Lecture
• LabTest 2 Guide
• Assessment Details
• Sample Questions
• Testing Your Code
• Manual Testing
• Automatic Testing
• Python unittest
• TestCase
• Assertion
• Check the process time
ENGG1810/9810
Test Driven
Development
A way of software development that requires
you to write the tests for a given function first,
before you even write the function!
ENGG1810/9810
Python unittest
import unittest
unittest contains both a testing framework and a test runner.
It requires that:
• You put your tests into classes as methods
• You use a series of special assertion methods in the unittest.TestCase class
Individual unit of testing. A collection of test cases, test It orchestrates the execution of
Checks for a specific response suites, or both. It aggregates tests and provides the
to a particular set of inputs tests that should be executed outcome to the user
ENGG1810/9810
Python unittest
import unittest
unittest contains both a testing framework and a test runner.
It requires that:
• You put your tests into classes as methods
• You use a series of special assertion methods in the unittest.TestCase class
Test Case
Test Case
ENGG1810/9810
O Sittefanon
hotestcaseednIa caimatenuane
Gate's.EE Use the test functions(methods)
by adding self as the first argument
xp
ENGG1810/9810
Python unittest
Python unittest
Test Runner:
This is a command line entry point.
It means that if you execute the script alone by running Python unittest_ex1.py
at the command line, it will call unittest.main(). This executes the test runner by
discovering all classes in this file that inherit from unittest.TestCase.
ENGG1810/9810
Python unittest
Python unittest
Is this enough?
ENGG1810/9810
Python unittest
ENGG1810/9810
Today’s Lecture
• LabTest 2 Guide
• Assessment Details
• Sample Questions
• Testing Your Code
• Manual Testing
• Automatic Testing
• Python unittest
• TestCase
• Assertion
• Check the process time
ENGG1810/9810
Python Process_time
You can also check the processing time using time module
https://docs.python.org/3/library/time.html#time.process_time
ENGG1810/9810
Python Process_time
You can also check the processing time using time module
https://docs.python.org/3/library/time.html#time.process_time
ENGG1810/9810
Python Process_time
Let’s have a look how we can check the process time of the multiple files/modules
https://docs.python.org/3/library/importlib.html
https://docs.python.org/3/library/glob.html
https://docs.python.org/3/library/os.html
ENGG1810/9810
Python Process_time
Let’s have a look how we can check the process time of the multiple files/modules
system
Let’s go through with Caren
ofpii
system
(during the lecture)
inside
going
folders
https://docs.python.org/3/library/importlib.html
https://docs.python.org/3/library/glob.html
https://docs.python.org/3/library/os.html
ENGG1810/9810
THANKS FOR
WATCHING
Good luck in studying