Spring Certified Professional 2023 · Free Practice Question Easy

Question 3

_______ tests are small, isolated tests that verify the correctness of a specific unit of code, typically a single function or method, in isolation from the rest of the system.

  • A

    integration

  • B

    performance

  • C

    unit

  • D

    functional

Reveal correct answer

Correct answer: C

Explanation

A unit test is an automated piece of code that invokes a unit of work in the system and then checks a single assumption about the behavior of that unit of work.

https://www.artofunittesting.com/definition-of-a-unit-test


Additional details:

A good unit test is:

  • Able to be fully automated

  • Has full control over all the pieces running (Use mocks or stubs to achieve this isolation when needed)

  • Can be run in any order if part of many other tests

  • Runs in memory (no DB or File access, for example)

  • Consistently returns the same result (You always run the same test, so no random numbers, for example. save those for integration or range tests)

  • Runs fast

  • Tests a single logical concept in the system

  • Readable

  • Maintainable

  • Trustworthy (when you see its result, you don’t need to debug the code just to be sure)

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need