Introduction Flashcards Preview

Software Unit Tests > Introduction > Flashcards

Flashcards in Introduction Deck (19)
Loading flashcards...
1

What's triple A in unit tests?

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

2

What's type safe on c#?

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

3

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

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

4

What's a lambda expression?

A nameless function.

5

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

Use the within method.

6

One example of type safe assert and one regular

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

7

What's the four most common constraint assertions?

Is, That, Does and Has (for lists)

8

Is it ok having multiple asserts in the same test?

Yes, if they are asserting the same behavior.

9

How to comment out a code block?

ctrl + k + ctrl +c

10

How to ignore a test in unit?

Use the Ignore attribute and define a reason message

11

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

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

12

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

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

13

What are the principles of good unit tests?

Fast, Repeatable, Isolated, Trustworthy and Valuable

14

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

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

15

What's data-driven-tests?

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

16

Can you assert the expected value outside the method?

Yes. Via ExpectedResult property within the TestCase attribute.

17

How to centralize test case data?

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

18

In which cases combinatorial and sequential test cases are useful?

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

19

Is it possible to centralize test case data in files?

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