Extra Lecture: How to write good tests Flashcards

1
Q

What are the two main types of program testing?

A
  1. FUNCTIONAL tests (ensure that a program works as expected i.e. does what it is expected to do)
  2. NON FUNCTIONAL tests (ensures that a program runs well)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the functionality of a program?

A

The functionality of a program is the set of ACTIONS, OPERATIONS, and BEHAVIOUR of a program. It’s functionality is about what it DOES

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Functional Testing: What are the three main risks in writing tests?

A
  1. Not testing a feature called out in the specification.
    Thus there is a danger that your software will not then have that feature.
  2. Not testing an unusual input for a feature.
    Thus there is a danger that the software will normally work, but won’t work in that particular case
  3. Misunderstanding a feature described in the specification.
    Thus there is a danger that the software passess all tests but doesn’t do what was required.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can we reduce the probability of these three risks?

A
  1. Making sure that the tests are derived from the specification, not from the code.
  2. Having different people writing the tests from those writing the code.
  3. If the same programmer writes the code and tests, the programmer should write the tests
    before writing the code.

i.e. these techniques seperate the development of the code from the developement of the tests. This makes it more likely that the tests are independent and not derived from the code. Also encourages double checking.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is black box testing?

A

During black box testing, the verification team only looks at the inputs and outputs.
The testers do not look at the code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is exhaustive testing?

A

An exhaustive test checks that the all possible inputs give the correct results. This is the ideal.
However, it is only possible for the simplest programs.

The alternative is to design a series of tests that checks every type of function described in the
specification at least once.
The test designer must develop a set of tests that exercises all of the functions.

It is important to understand that the number of tests doesn’t matter.
What matters is that the functionality is thoroughly tested.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are edge case tests?

A

Edge case testing means testing both sides of the boundaries. e.g. for a user inpu where the requested values are between 1 to 100 inclusive. Must test with 0 and 1, as well as 100 and 101 to check that the expected outcome is achieved for all.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is code coverage?

A

The code coverage is a report which indicates which code in the script has been executed and which
has not been executed. The code coverage is summed over all of the tests.
Code coverage is normally measured as a percentage.

There are 3 types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the three types of code coverage?

A

The three main types of code coverage are:

  1. LINE COVERAGE which measures whether each line is executed or not.
  2. BRANCH COVERAGE which measures whether each branch is executed or not.
  • branch refers to a possible path the code can take due to control flow, like if, else, for, while, try, etc. *
  1. CONDITION COVERAGE which measures whether each combination of true/false values is tested or not.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Some key things to remember when testing

A
  • Be careful, 100% code coverage does not prove that the program is fully correct.
    Some bugs don’t show up with code coverage measurements.
    However, code coverage is a useful metric.

If a feature has not been tested, you must assume that it does not work.

A common mistake is assuming that feature works. Every time that the code is changed, all of the tests should be re-run. Re-running all the tests is called a regression test.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly