testing and debugging

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/28

flashcard set

Earn XP

Description and Tags

week

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

29 Terms

1
New cards

What is an error?

when your program doesn’t work as intended

2
New cards

Compile-time errors

errors that happens when you try to write your code this can be syntax error

3
New cards

Runtime errors

occurs when a program is running

  • you could be dividing by zero or index error

4
New cards

Logical errors:

mistakes in your code or algorithm and your code runs but it doesn’t work as intended

5
New cards

What is a bug?

flaws in a program

  • originated in 1940 when a bug(mont) was found in a computer

6
New cards

Debugging

  • art of removing bugs in a program

  • is a processing of finding isolating and removing errors in a code

7
New cards

the first bug

  • found in 1947

  • real bug found by Grace Hopper and her team at harvard

8
New cards

“Compile”-time Error

  • found by python interpreter

  • syntax error

  • the program doesn’t follow the programming language

  • IndentationError

  • NameError (misspelling key words)

9
New cards

runtime error

  • the program structure is correct but is doesnt work as intended

  • ZeroDivisionError

  • TypeError

  • NameError (variable thats not defined )

  • FileNotFoundError:

  • KeyError

  • indexError

10
New cards

syntax error

  • happens when the code is not following the rules

  • Program does not pass checking/compiling stage

11
New cards

Logic Error

Program passes checking/compiling and runs but produces incorrect results or no results - because of a flaw in the algorithm or implementation of algorithm.

12
New cards

test

uncovering errors

13
New cards

Debug

finding the cause of the error

14
New cards

Exhaustive testing, also known as brute-force testing

  • a testing strategy where every possible input in its domain is use to test the program

15
New cards

Characteristics of Exhaustive Testing:

  • Test Coverage: ensure to test every possible input to make sure every scenario is covered

  • Expected Outputs: for every input the expected output must be predetermined so it can be compared with the actual values

  • Full Validation: it provides the high level of confidence since each case was tested

16
New cards

Pros of Exhaustive Testing:

  • validation

  • no assumption

17
New cards

Cons of Exhaustive Testing:

  • scalability

  • resource intensive

18
New cards

example for Exhaustive testing

Exhaustive testing

But how do we test for all values of integers?

def Threshold(val):

if val>10000:

val=10000

return val

This simple program asks the user for one integer – how many possible inputs in Python?

answers

  • Boundary values: 1001 1000 999

  • Edge cases: very large number 1 000 000 000, a negative number -100 and zero

19
New cards

Random Testing

  • randomly select subset of possible input in the domain

  • Sampling random integers from a wide range (positive, negative, very large, very small).

  • Test Coverage: generate random numbers

20
New cards

Equivalence Class

  • divides the input data into classes and these classes represent a set of inputs that will behave the same

  • example :valid age is between 18 and 65

  • therefore your equivalence classes are going to be

  • [18; 20; 44; 65]

  • [values under 18]

  • [values greater than 65]

21
New cards

Boundary Value

  • focuses on testing boundaries between equivalance classes

  • it assumes that errors are likely to appear on these values

  • example

  • input and accepts valid ages between 18 and 65

  • boundary values

  • just below 18 : 17

  • at min valid age: 18

  • at max valid age 65

  • above 65: 66

19 is not a boundary value since if falls under the valid age

22
New cards

path testing

creates case test that cover each possible path

23
New cards

Statement Coverage

line coverage

makes sure every line in a code is executed at least once during testing

24
New cards

black box testing

Exhaustive Testing

Random Testing

Equivalence classes

boundary values

25
New cards

glass box testing

Path Coverage,

Statement Coverage

26
New cards

tracing

you insert temporary statement in your code to track and output values during the execution

27
New cards

Debugging

the process of finding errors/bugs in a code

28
New cards

binary numbers

  • computer represents them using the presence or the absence of voltage

  • binary is a base two system number and it only uses two numbers 0 and 1

  • 1101-base2​ is a binary number

29
New cards

binary code

def convert_to_binary(decimal):

result_string = ""

while decimal > 0:

remainder = decimal % 2

decimal = decimal // 2

result_string = str(remainder) + result_string # Add remainder to the front of the result string

return result_string