C9: Unit Testing in C Flashcards

1
Q

What are mistakes in software called?

A

bugs

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

What is software verification?

A

Verification is making sure software fulfills its specification.

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

What is software validation?

A

Validation means making sure the software fulfills the users’ needs (acceptance tests).

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

What are the different methods of software verification?

A

Formal proofs, reviews, analysis and tests.

  1. formal proofs…
  2. reviews - code reviews, design reviews,…
  3. analysis - static code analysis, dynamic resource usage measurements,…
  4. Tests - model driven, unit tests, …
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is test automation?

A
using a tool to execute
tests automatically (instead of manually)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is model-driven (automated) testing?

A

model-driven (automated) testing means using a (formal) model of the software under test to create test cases (and pass criteria) automatically.

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

What is regression testing?

A

Regression testing is repeating existing tests again to make sure that modifications in previously tested software did not cause any new bugs or otherwise break the system.

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

What are the different kind of tests?

A
  1. Unit tests (test one unit), 2. integreation tests (test multiple units) and
  2. system tests (test whole system)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the different kinds of system tests?

A
  1. functional tests
  2. performance tests
  3. stress tests
  4. user interface tests
  5. recovery tests
  6. failover tests
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are performance tests?

A

A type of system test: Performance test: tests behaviour of system (e.g. reaction time) in specified workload boundaries

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

What are stress tests?

A

A type of system test: Stress test: performance test that overloads the system.

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

What are recovery tests?

A

A type of system test: Recovery test: tests if system can recover
after (full) system failure.

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

What are failover tests?

A
A type of system test: Failover test: tests if system works as
specified during (partial) system failure
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is an integration test?

A

Integration testing checks the interplay of several units and checks whether they work together correctly.

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

What is a resource test?

A

It is a test to see whether modules misbehave due to scarce resources (integration testing).

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

What is unit testing?

A

Unit testing makes sure each unit works correctly, given the right input and assuming all other units are correct. Unit tests are also WHITE BOX tests to make sure that one individual unit works correctly independently of all other units.

17
Q

What is white box and black box testing?

A

white box testing- we have source code.

black box testing - we do not have source code.

18
Q

What are the F.I.R.S.T properties of unit tests?

A

Fast, Isolated, Repeatable, Self-Verifying, Timely:
Fast - measure in fraction of a second,
Isolated - single reason to fail,
Repeatable; obtain same results every time,
Self-Verifying; test fails or passes unambiguously,
Timely small time gab between writing test and code.

19
Q

What is a test double?

A
A test double impersonates some function, data, module or library during a test.  Other variations of a test double are fake, mock, stub.... For example:
test dummy
test stub
test spy
mock object
fake object
exploding fake
20
Q

When should you use test doubles?

A
 Hardware independence
 Inputs that are difficult to produce
 Slow collaborator
 Dependency on something volatile
 Dependency on something under
development
 Dependency on something that is difficult
to set up and configure
21
Q

How do we get rid of dependencies to other units or external factors (OS, HW)?

A

By isolating the Unit using test doubles instead of collaborators (some function, data, module or device outside the code under test that the code depends on.) This is possible by using

  1. link-time substitution,
  2. function/pointer substitution/dependency injection,
  3. preprocessor substitution.
22
Q

What is link-time subsitution?

A

Link-time substitution is used to break dependency of a code under testing and its DOC/collaborator (i.e. function, etc. outside the code that the tested code depends on.) . It does this by:

  1. providing different DOC implementation to linker when testing,
  2. replacing DOC for whole unit test executable
23
Q

What is preprocessor substitution?

A

is used to break dependency of a code under testing and its DOC/collaborator (i.e. function, etc. outside the code that the tested code depends on.) . It does this by: It is a last resort if link-time sub or pointer sub doesn’t work.
use preprocessor directives in CUT source code to redefine names and/or include different header files when testing.

24
Q

How do you test functions that print a string?

A

You can recreate the output by reproducing the string and then using the function TEST_ASSERT_EQUAL_STRING()

25
Q

What is a mock object?

A

A mock object is used in unit testing to check whether indirect side effects of a function are correct.