Recall & Review
beginner
What is a test fixture in Kotlin testing?
A test fixture is the fixed state of a set of objects used as a baseline for running tests. It includes setup data and environment needed before tests run.
Click to reveal answer
beginner
Which Kotlin testing annotation is used to run code before each test method?
The @BeforeEach annotation runs the setup code before each test method to prepare the test environment.
Click to reveal answer
beginner
What is the purpose of the @AfterEach annotation in Kotlin tests?
It runs cleanup code after each test method to reset or release resources used during the test.
Click to reveal answer
intermediate
How does @BeforeAll differ from @BeforeEach in Kotlin testing?
@BeforeAll runs once before all tests in a class, while @BeforeEach runs before each individual test method.
Click to reveal answer
intermediate
Why is it important to use test fixtures and lifecycle methods in automated tests?
They ensure tests run in a consistent environment, avoid side effects between tests, and help isolate failures for easier debugging.
Click to reveal answer
Which annotation in Kotlin runs code before each test method?
✗ Incorrect
@BeforeEach runs setup code before every test method to prepare the environment.
What does a test fixture typically include?
✗ Incorrect
Test fixtures include the data and environment setup needed before running tests.
Which annotation is used to clean up after each test method?
✗ Incorrect
@AfterEach runs cleanup code after each test method.
When is @BeforeAll executed in Kotlin tests?
✗ Incorrect
@BeforeAll runs once before all tests in the test class.
Why should tests use lifecycle methods like @BeforeEach and @AfterEach?
✗ Incorrect
Lifecycle methods help keep tests isolated and consistent by setting up and cleaning the environment.
Explain what a test fixture is and why it is important in Kotlin testing.
Think about what you need before running a test to make it reliable.
You got /3 concepts.
Describe the difference between @BeforeEach and @BeforeAll annotations in Kotlin testing lifecycle.
Consider how often the setup code runs in each case.
You got /3 concepts.