produtos/pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.matheus.maven</groupId>
<artifactId>produtos</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>produtos</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.8</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.0.Final</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.8</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
ProdutoTeste.java
package br.com.matheus.maven;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class ProdutoTeste {
@Test
protected void verificaPrecoComImposto() throws Throwable {
String nome = "juquinha";
double preco = 0.10;
Produto bala = new Produto("juquinha", 0.10);
assertEquals(0.11,bala.getPrecoComImposto(),0.00001);
assertEquals(nome,bala.getNome());
assertEquals(preco,bala.getPreco(),0);
}
}
Produto.java
package br.com.matheus.maven;
public class Produto {
private final String nome;
private final double preco;
public Produto(String nome, double preco) {
super();
this.nome = nome;
this.preco = preco;
}
public String getNome() {
return nome;
}
public double getPreco() {
return preco;
}
public double getPrecoComImposto() {
return preco * 1.1;
}
}