'Direct dependency and transitive dependency in test scope through maven

Is a direct dependency available in test scope while using maven? So, if user-management have a dependency on utility module in normal flow:

<dependency>
            <groupId>GROUP ID</groupId>
            <artifactId>utils</artifactId>
            <version>${version.product}</version>
</dependency>

Then will it also be available in test scope while testing user-management?

Is transitive dependency available in test scope while using mavan? like User-managment-> utility-> plan

Then I don't think it would be available as maven document Maven: The Complete Reference 3.4. Project Dependencies.

So how can I include transitive dependency in test scope?

While testing user-management I am using some domain objects and service classes of other modules also.

I am shocked with this and it would be great help if someone can help that how to run these test cases as a project level.

Thanks in advance!!!!!



Solution 1:[1]

During tests, the test output directory and main output directory are the first two things on the test classpath, respectively. Then come all of your direct and transitive dependencies of all scopes, following the rules for scopes and transitive dependencies in the link you mentioned and in the order you've declared them in the POM. Find details about each scope in "Dependency Scope" on the Maven site.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ryan Stewart