0
0
Microservicessystem_design~5 mins

Unit testing services in Microservices - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main goal of unit testing in microservices?
To verify that each individual service component works correctly in isolation, ensuring its logic is correct before integration.
Click to reveal answer
beginner
Why should unit tests avoid calling external services or databases?
Because unit tests should be fast, reliable, and isolated. Calling external services makes tests slower and less predictable.
Click to reveal answer
intermediate
What technique is commonly used to isolate dependencies in unit testing microservices?
Mocking or stubbing dependencies to simulate their behavior without invoking real implementations.
Click to reveal answer
intermediate
How does unit testing contribute to the scalability of microservices?
By catching bugs early in small components, unit testing reduces errors in production and supports easier scaling of individual services.
Click to reveal answer
beginner
What is a good practice for naming unit tests in microservices?
Use descriptive names that clearly state the condition and expected outcome, like 'shouldReturnErrorWhenInputIsInvalid'.
Click to reveal answer
What is the primary focus of unit testing in microservices?
ATesting user interface responsiveness
BTesting the entire system end-to-end
CTesting network latency between services
DTesting individual service components in isolation
Which of the following is NOT a reason to mock dependencies in unit tests?
ATo test real database performance
BTo speed up test execution
CTo isolate the unit under test
DTo avoid flaky tests caused by external services
What is a sign of a well-written unit test?
AIt clearly describes the tested behavior and runs quickly
BIt depends on multiple external services
CIt runs slowly and intermittently fails
DIt tests multiple services at once
Which tool or technique is commonly used to simulate dependencies in unit tests?
AProfiling
BLoad testing
CMocking
DLogging
Why is unit testing important before integration testing in microservices?
AIt tests the entire system's user interface
BIt ensures individual parts work correctly, reducing integration errors
CIt measures network bandwidth
DIt replaces the need for integration testing
Explain how mocking helps in unit testing microservices and why it is important.
Think about how you can test a part without involving others.
You got /3 concepts.
    Describe best practices for writing effective unit tests for microservices.
    Imagine explaining to a friend how to write a good test.
    You got /4 concepts.