What is the difference between maven surefire plugin and maven surefire dependency

Viewed 196

Maven Surefire Plugin

[...] org.apache.maven.plugins maven-surefire-plugin 3.0.0-M6 [...]

Maven Surefire dependency

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version> </dependency>

what is the difference between the surefire plugin and dependency?

2 Answers

If you want to run tests during build, use the surefire plugin as plugin.

I see no immediate use case for using it as dependency.

If you just use surefire plugin dependency without mentioning the type of it, it just lies under your jars list. Whereas If you use it under plugins or If you specify the type of it then it may help you for unit testing and report generation and to get integrated with other testing frameworks. So If you are adding a dependency, you should add it like below

<dependency>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>3.0.0-M6</version>
  <type>maven-plugin</type>
</dependency>
Related