Skip to content
Sharp

Project Structure · interview question

In a Maven project, where should you define a dependency that is only needed for testing?

Multiple choiceMediumchapter-10-curatedpremiumproject-structurejava-modules-jpms
Choose one answer
Answer and explanation

Correct answer

A. In the <test> scope

Why

Dependencies needed only for testing should be defined in the <test> scope. This ensures they are available in the test phase but not included in the final build product.

Test yourself on Project Structure

A free test with instant, explained results. No account needed.

Start free test
All Project Structure questions →