Unit tests Flashcards

1
Q

Why use unit tests?

A

Unit tests allow you to quickly catch bugs & errors that were introduced by a change in the code.

They will test the functionality of a specific piece of code, the smaller the unit the better as this allows for precise identification of the bug.

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

What are local tests?

A

Unit tests that only run on your machine, using the Java Virtual Machine (JVM). These tests shouldn’t test android objects, only kotlin/java objects.

We use local tests for business logic. JUnit is often use for these tests.

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

What are instrumented tests?

A

Unit tests that run on an android device or emulator. They have access to instrumentation information like the context of an activity. We use these tests to test android code.

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

What is Mockito used for?

A

For creating mock objects instead of having a unit test call a remote server for a response.

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

What are UI tests?

A

Simulates a person using the app, where a robot will interact with the widgets on the screen. Expresso is commonly used for these types of tests.

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

Should you test external libraries in your unit tests?

A

No, external libraries can change and should not be included in unit tests.

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

What experience have you had with Unit tests?

A

I’ve created NUnit tests (which is a unit testing framework for .NET) to test the business logic of the RSH app.

Example: Unit test for testing an email validation method.

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