Introduction Flashcards

1
Q

What’s triple A in unit tests?

A

It’s a basic test structure. Every test has the same structure, which is: Assert, Act and Assert.

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

What’s type safe on c#?

A

Means that the compiler guarantees the types you’re using within your app. This is not satisfied when you use “MyProperty” kind of access.

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

What’s classic and constraint-based asserts on unit tests?

A

Classic matches the value, e.g: Assert.Equals(expected, actual). Constraint is based on a prose: Assert.That(1, Is.EqualTo(actualValue).

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

What’s a lambda expression?

A

A nameless function.

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

How to test a float value in c# / nunit?

A

Use the within method.

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

One example of type safe assert and one regular

A

Use matches method for type-safe lambda expressions and Property(“MyPropName”) for a non-type-safe.

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

What’s the four most common constraint assertions?

A

Is, That, Does and Has (for lists)

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

Is it ok having multiple asserts in the same test?

A

Yes, if they are asserting the same behavior.

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

How to comment out a code block?

A

ctrl + k + ctrl +c

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

How to ignore a test in unit?

A

Use the Ignore attribute and define a reason message

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

How to separate tests in tests or category? And how to filter them?

A

Using Category attribute. Ignore via visual studio or –filter in dotnet test

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

What’s the basic test execution flow of the framework?

A

ctor, one-time setup, setup, test, tear down, one-time teardown and dispose

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

What are the principles of good unit tests?

A

Fast, Repeatable, Isolated, Trustworthy and Valuable

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

How to reuse the same test method but with different data?

A

Via TestCase attribute and defining the input values, then allowing the method below to receive the input values and the expected value.

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

What’s data-driven-tests?

A

Is a way to test using different set of input values for the same test method.

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

Can you assert the expected value outside the method?

A

Yes. Via ExpectedResult property within the TestCase attribute.

17
Q

How to centralize test case data?

A

By creating a class and method that returns an IEnumerable containing TestCaseData items. Then by specifying a TestCaseSource in the test method.

18
Q

In which cases combinatorial and sequential test cases are useful?

A

To test all sort of combinations of values and ensure they won’t raise an exception, for example.

19
Q

Is it possible to centralize test case data in files?

A

Yes, you can create a csv file and then create the logic to read it and generate TestCaseData itens.