Errors & Testing Flashcards
Week 1.6 (14 cards)
1
Q
syntax errors
A
- incorrect use of syntax
- found at run time
- will report where it found an error
- will report on the type of error
- will not always be precise
2
Q
syntax errors deep in the code
A
- the stack trace is more useful in these situations
- it locates the error but also the path to the error
- requires careful reading
3
Q
runtime errors
A
- the interpreter cannot always immediately find an error
- logical errors in program design
- external input that causes errors
4
Q
preventing errors
A
- diagnosing error messages
- careful programming to avoid syntax errors
- careful design to avoid logical and run-time errors
5
Q
defensive programming
A
- sanitise all external input
- anticipate and handle problems
-should be used whenever we interact with the external environment
6
Q
what is the behaviour of code determined by
A
- logical flow implemented in code
- values that variables take during execution of the code
7
Q
what should we anticipate with systematic testing
A
- expected logical paths taken through the code
- expected ranges of values of variables in the code and test appropriately
8
Q
what should the three things tests should cover
A
- size
- branching
- boundary (edge)
9
Q
types of size test cases
A
- test the cases when the collection is empty
- has a single element
- has multiple entries
- at the expected size during normal use
10
Q
branch tests
A
where code deals with a set of distinct situations your test cases should test all possible paths
11
Q
types of boundary tests
A
where your code has a boundary where its behaviour changes you should test:
- both sides of the boundary
- exactly the boundary case
12
Q
assert in python
A
- passes if it evaluates a Boolean expression as True
- creates an AssertionError, stopping execution, if it evaluates as False
13
Q
python my-function.py
A
assertions active
14
Q
python -O my-function.py
A
assertions inactive