Lecture 6 Flashcards

1
Q

What is the goal of testing?

A

Making sure that your software works as intended when being used as intended AND that your software doesn’t break when users do unintended and unexpected things.

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

What is a Unit Test?

A

a small test that tests the functionality of something inside one class

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

What is jUnit

A

jUnit is a unit test framework, which makes our lives easier by helping us write unit tests for our software.

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

Name 5 jUnit assertions

A
assertEquals()
assertNotEquals()
assertTrue()
assertFalse()
assertNotNull()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is important when using assertEquals() or assertNotEquals() in jUnit?

A

that there is an equals method for the classes that you’re trying to compare, because otherwise, it will use the default equals method, which uses “==”.

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

What are the 2 different types of tests?

A

Unit tests and integration tests

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

What is an integration test?

A

an integration test tests if classes work well together

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

When did you test enough?

A

Never. Tests can increase your certainty about your code, but we can never test all possible scenario’s and therefore we can never be 100% certain, that our code is correct.

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

How many tests do you need to cover a method?

A

To cover a method you need the same amount of tests as there are “branches” inside the method. To fully cover all possibilities you would also need tests for all possible outcomes for all possible branches. (BUT EVEN AFTER THIS, YOU ARE NOT 100% CERTAIN THAT YOUR CODE WILL ALWAYS WORK!)

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

How many assertions are preferably used in a unit test?

A

1

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