Lecture 6 Flashcards
What is the goal of testing?
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.
What is a Unit Test?
a small test that tests the functionality of something inside one class
What is jUnit
jUnit is a unit test framework, which makes our lives easier by helping us write unit tests for our software.
Name 5 jUnit assertions
assertEquals() assertNotEquals() assertTrue() assertFalse() assertNotNull()
What is important when using assertEquals() or assertNotEquals() in jUnit?
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 “==”.
What are the 2 different types of tests?
Unit tests and integration tests
What is an integration test?
an integration test tests if classes work well together
When did you test enough?
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 many tests do you need to cover a method?
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 many assertions are preferably used in a unit test?
1