This page lists down the practice tests / interview questions and answers for unit testing (general concepts) which applies for all programming languages. Those wanting to test their unit testing knowledge would find this test useful enough. The goal for this practice test is to help you do quick check of your knowledge in unit testing and prepare appropriately. More importantly, when you are preparing for interviews, these practice tests are intended to be handy enough. Those going for freshers / intern interviews in the area of programming language or for developer positions would also find these practice tests / interview questions to be very helpful.

Following topics have been covered as part of the test on this page:

  • Basic fundamentals/concepts around unit testing
  • Concepts related with test doubles
  • Concepts related with unit testing building blocks such as stub, mock, spy etc

Unit Testing Concepts (Brush up)

The following is quick notes for refreshing your concepts around unit testing:

  • Unit testing is testing block of code in isolation
  • Unit tests are intended to form the documentation for your code
  • It is difficult to write unit tests having high code coverage for code having high cyclomatic complexity
  • Unit tests uses test doubles such as stub, spy, mock for mocking external dependencies
  • It is important to do code refactoring and bring down code cyclomatic complexity to achieve high code coverage
  • It is easier to achieve higher code coverage if the block of code is cohesive enough.


Practice Tests on Unit Testing

Unit tests are written to test ________

Correct! Wrong!

Unit tests are easier to write for the code _______ in cohesiveness

Correct! Wrong!

Unit tests can be written based on which of the following methodologies?

Correct! Wrong!

In Test pyramid, unit tests comes ________

Correct! Wrong!

Which of the following forms test doubles in the unit tests?

Correct! Wrong!

Which of the following when used in unit tests replace the external methods in entirety?

Correct! Wrong!

Which of the following when used in unit tests as test double in place of another/dependent functions does not affect the behavior of the function?

Correct! Wrong!

Which of the following is a popular unit test framework for Javascript?

Correct! Wrong!

Which of the following is a popular unit test framework for Java?

Correct! Wrong!

Which of the following test double can be used to trigger code path which would not otherwise trigger?

Correct! Wrong!

Unit Test Interview Questions - Set 1
You did extremely well!!
You did reasonably well!!
Better luck next time!!

Share your Results:

Please feel free to share your thoughts on concepts / interview questions / practice tests on unit testing listed on this page.


Ajitesh Kumar

I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. For latest updates and blogs, follow us on Twitter. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking. Check out my other blog, Revive-n-Thrive.com

Recent Posts

Linear Regression T-test: Formula, Example

Last updated: 7th May, 2024 Linear regression is a popular statistical method used to model…

7 hours ago

Feature Engineering in Machine Learning: Python Examples

Last updated: 3rd May, 2024 Have you ever wondered why some machine learning models perform…

4 days ago

Feature Selection vs Feature Extraction: Machine Learning

Last updated: 2nd May, 2024 The success of machine learning models often depends on the…

5 days ago

Model Selection by Evaluating Bias & Variance: Example

When working on a machine learning project, one of the key challenges faced by data…

5 days ago

Bias-Variance Trade-off in Machine Learning: Examples

Last updated: 1st May, 2024 The bias-variance trade-off is a fundamental concept in machine learning…

6 days ago

Mean Squared Error vs Cross Entropy Loss Function

Last updated: 1st May, 2024 As a data scientist, understanding the nuances of various cost…

6 days ago