TDD Flashcards

1
Q

In TDD, what is a Dummy?

A

They are simple mocks that represent external resources. They usual return the same result regardless of input parameters or number of times called

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

In TDD, what are Stubs/Fakes?

A

Similar to Dummy objects, but they will return a different result depending on the input parameters, however they still have no ‘knowledge’ of how many times they’ve been called

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

In TDD, what are Mocks?

A

They are a step up from Stubs/Fakes. Not only do they return different results depending on the input, they also have rules defining how often and when methods should be called

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

What types of methods should you NOT mock?

A

Private Methods

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

Convert the following function so that it’s Mocked to allow any integer value when called and always return 10 in a test: class MyClass() { public int WhatIsTheSquareOf(int x) { return x*x;} }

A

private Mock _myClass; _myClass.Setup(x => x.WhatIsTheSquareOf(It.IsAny()).Returns(10);

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

When you find / are told of a bug, what should be the first thing you do?

A

Write a unit test to ‘prove’ the bug. You’re fix should then stop the text from failing.

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

What are the 3 stages of a Unit Test?

A

Arrange

Act

Assert

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