Recall & Review
beginner
What is unit testing?
Unit testing is the process of testing small parts of code, called units, to make sure each part works correctly by itself.
Click to reveal answer
beginner
Why do we write unit tests?
We write unit tests to find bugs early, make code easier to change safely, and ensure each part of the program works as expected.
Click to reveal answer
beginner
What is a test case in unit testing?
A test case is a small piece of code that checks if a specific function or method returns the right result for given inputs.
Click to reveal answer
beginner
What does
@Test annotation do in JUnit?The
@Test annotation tells JUnit that the method below it is a test case to run automatically.Click to reveal answer
intermediate
What is the difference between unit testing and integration testing?
Unit testing checks small parts alone, while integration testing checks if different parts work well together.
Click to reveal answer
What is the main goal of unit testing?
✗ Incorrect
Unit testing focuses on testing small parts of code individually to ensure they work correctly.
Which JUnit annotation marks a method as a test case?
✗ Incorrect
The @Test annotation tells JUnit to run the method as a test case.
What should a unit test ideally test?
✗ Incorrect
Unit tests focus on testing a single function or method in isolation.
Which of the following is NOT a benefit of unit testing?
✗ Incorrect
Unit testing helps but does not replace all manual testing; other tests are still needed.
What does a failing unit test indicate?
✗ Incorrect
A failing test usually means the code being tested does not behave as expected and may have a bug.
Explain what unit testing is and why it is important.
Think about testing one small piece of code at a time.
You got /4 concepts.
Describe how JUnit helps in unit testing Java code.
Focus on JUnit features that make testing easier.
You got /4 concepts.