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 ________
Unit tests are easier to write for the code _______ in cohesiveness
Unit tests can be written based on which of the following methodologies?
In Test pyramid, unit tests comes ________
Which of the following forms test doubles in the unit tests?
Which of the following when used in unit tests replace the external methods in entirety?
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?
Which of the following is a popular unit test framework for Java?
Which of the following test double can be used to trigger code path which would not otherwise trigger?
Please feel free to share your thoughts on concepts / interview questions / practice tests on unit testing listed on this page.
He has also authored the book, Building Web Apps with Spring 5 and Angular.
Latest posts by Ajitesh Kumar (see all)
- How to Upgrade from Angular 5 App to Angular 6 - May 5, 2018
- Java – Configure MySQL for Google Appengine (Standard) - April 27, 2018
- Google Recaptcha with Angular and Spring App – Example - April 22, 2018