Dependencies

Figure 650. Adding test capabilities Slide presentation
<project ... maven-4.0.0.xsd"> ...
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>...
import org.junit.Test;
import org.junit.Assert;

public class AppTest {
  @Test
  public void doTest() {
    Assert.assertEquals(1, 1);
  }
first> mvn test
[INFO] Scanning for projects...
Running de.hdm_stuttgart.mi.sd1.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.053 sec

Figure 651. Dependency listing Slide presentation
first> mvn dependency:tree
        ...
[INFO] de.hdm_stuttgart.mi.sd1:first:jar:0.9
[INFO] \- junit:junit:jar:4.12:test
[INFO]    \- org.hamcrest:hamcrest-core:jar:1.3:test
  • ~/.m2/repository/junit/junit/4.12/junit-4.12.jar

  • ~/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar


Figure 652. Absence of hamcrest in pom.xml Slide presentation
<project ... maven-4.0.0.xsd"> 
      ...
<!-- no such entry -->
  <dependency>
    <groupId>org.hamcrest</groupId>
    <artifactId>hamcrest-core</artifactId>
    <version>1.3</version>
    <scope>test</scope>
  </dependency>
      ...

Figure 653. ~/.m2/repository/junit/junit/4.12/junit-4.12.pom Slide presentation
<dependency>
  <groupId>org.hamcrest</groupId>
  <artifactId>hamcrest-core</artifactId>
  <version>1.3</version>
  </dependency>
</dependencies>

Figure 654. Transitive dependencies Slide presentation

Figure 655. Oblivious to test implementation: TestNG Slide presentation
<project ... maven-4.0.0.xsd"> ...
  <dependencies>
    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>6.14.3</version>
      <scope>test</scope>
    </dependency>...
import org.testng.annotations.Test;
import org.testng.Assert;

public class AppTest {
  @Test
  public void doTest() {
    Assert.assertEquals(1, 1);
  }
testng> mvn test
Running de.hdm_stuttgart.mi.sd1.AppTest
Configuring TestNG with: org.apache.maven.surefire...
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.372 sec