MockTesting Flashcards

1
Q

How can we test software economically? What are the 5 principles of testing?

A
  1. Specify Input and Output
  2. Seperate Creation and Testing -> a software developer shouldn’t test his own program
  3. Completeness of Tests -> Test cases also must consider invalid and unexpected input
  4. Testing is an Investement -> avoid throwaway test cases. Use automatic testing, that can be repeated at any point in time
  5. Error Clusters -> errors tend to com ein clusters, means: if you find an error in a section, this section is very likely to have more errors.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is regression testing?

A

When we save test cases and run them again later after changes to other components of the program.

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

What’s a Test Double?

A

Any object or component that is installed in place of the real component in order to run a test.

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

Which of the three types of test doubles

  • Fakes
  • Stubs
  • Spies

is. ..
a) the least complex
b) the most complex

A

a) Stubs

b) Fakes

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

What can a Mock test do, that a simple unit test can’t?

A

Behavior of the System under test can be tracked by the use of mock object

e.g. can we check how many times a method was called

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

What’s the pattern for mock testing?

A
  1. Create a mock object
  2. Specify the expected behavior of the mock
  3. Test / use the mock
  4. Verify behavior
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Name some reasons, when we would use mock objects

A

The actual object has non-deterministic behavior

The actual object is difficult to set up

The actual object is slow

The actual object has a user interface

The test needs to ask the real object about how it was used (→ e.g., if a callback function was called)

The actual object does not yet exist

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

What’s the purpose of verify(….) ?

A

To test the behavior with the mock object // e.g. to check if a method got called

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

What is “Stubbing”?

A

When we teach the mock object how to behave when…thenReturn… or doReturn…when….

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