To be clear, this is the passage of the documentation:
test
This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases. This scope is not transitive.
Those two sentences handle the cases that can rise during dependency resolution: declaring a dependency in the POM, and considering transitive dependencies of dependencies declared in the POM.
The first part means that having in your POM a dependency with scope test
will result in that dependency being only available in the test classpath. Put another way, it applies when you have explicitly declared a dependency in the POM:
<dependency>
<!-- GAV coordinates -->
<scope>test</scope>
</dependency>
Trying to use it in main Java classes (under src/main/java
) will result in a compilation error, and using it in test Java classes (under src/test/java
) will work fine.
The second part applies to the dependencies of dependencies that are declared in the POM. It means that test scoped dependencies of the dependencies declared in the POM will be omitted. For example, suppose you are having a compile-time dependency on a library called A, and A itself has a test-scoped dependency on B; then B will be ignored in the dependency resolution, and will not end up on your classpath. The logic is that, A needs B to run its tests, but as a consumer of A, you don't need B to be able to use it. Those test-scoped dependencies will always be omitted, whatever the scope of the declared dependency you have (whether it is compile
, runtime
, or even test
), which is why the test
scope is called not transitive.
Put another way, it all depends what is meant by "some pom". When you're declaring a test scoped dependency in your POM, it will be available on the test classpath. All of its compile and runtime transitive dependencies will be available on the test classpath as well, because the compile
and runtime
scope are transitive and will be inherited with a scope of test
. When the POM is not your own, the test scoped dependencies will be always omitted (therefore its dependencies will be omitted as well).