0
0
JUnittesting~5 mins

Test classes and naming in JUnit - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
Why should test classes have clear and descriptive names?
Clear and descriptive test class names help quickly understand what functionality is being tested, making maintenance and debugging easier.
Click to reveal answer
beginner
What is a common naming convention for JUnit test classes?
A common convention is to name the test class after the class it tests, followed by 'Test'. For example, for a class 'Calculator', the test class is 'CalculatorTest'.
Click to reveal answer
intermediate
How should test methods be named inside test classes?
Test methods should have descriptive names that explain what behavior or scenario they test, often using a pattern like 'methodName_condition_expectedResult'.
Click to reveal answer
intermediate
What is the benefit of grouping related tests into separate test classes?
Grouping related tests improves organization, makes tests easier to find, and helps isolate failures to specific areas of the code.
Click to reveal answer
beginner
True or False: Test classes should be placed in the same package as the classes they test.
True. Placing test classes in the same package helps access package-private members and keeps tests organized alongside the code under test.
Click to reveal answer
What suffix is commonly used for JUnit test classes?
AVerify
BSpec
CCheck
DTest
Which of the following is the best test class name for testing a class named 'OrderProcessor'?
AOrderProcessorTest
BTestOrderProcessorClass
CProcessorOrderTests
DOrderTestProcessor
Why is it important to give descriptive names to test methods?
ATo make test reports easier to understand
BTo reduce the number of tests needed
CTo make tests run faster
DTo avoid writing assertions
Where should test classes ideally be located in a Java project?
AInside the main application package
BIn the same package as the classes they test
COnly in the root source folder
DIn a completely separate unrelated package
What is a good practice when you have many tests for different features of a class?
APut all tests in one large test class
BWrite tests without any naming conventions
CGroup related tests into separate test classes
DAvoid writing tests for minor features
Explain why naming test classes clearly is important and describe a common naming convention for JUnit test classes.
Think about how you find and understand tests when debugging.
You got /3 concepts.
    Describe how you would organize test classes and test methods for a large class with many features.
    Consider how to keep tests easy to read and maintain.
    You got /3 concepts.