0
0
JUnittesting~5 mins

Unit testing concept in JUnit - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ATest database performance
BTest the whole application at once
CTest user interface design
DTest individual parts of code separately
Which JUnit annotation marks a method as a test case?
A@Test
B@Verify
C@Check
D@Run
What should a unit test ideally test?
AMultiple classes working together
BThe entire system's performance
CA single function or method
DUser acceptance criteria
Which of the following is NOT a benefit of unit testing?
AFinding bugs early
BReplacing manual testing completely
CMaking code easier to maintain
DHelping safe code changes
What does a failing unit test indicate?
AThe tested code may have a bug
BThe test code is wrong
CThe program is finished
DThe test passed successfully
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.