Code Coverage with SonarQube and Jacoco (#10674)
* Code Coverage with SonarQube and Jacoco * SonarQube and Jacoco * Delete SonarQube and Jacoco From the Root directory * SonarQube and JaCoCo * SonarQube And JaCoCo * BAEL-4636 : Code Coverage with SonarQube and Jacoco * Shifted to testing-modules/testing-libraries-2 * Removing this project to make a single project * Code Coverage with SonarQube and Jacoco * Formatting in pom.xml file * Delete Directory * Delete unused directory * SonarQube And JaCoCo * SonarQube And JaCoCo
This commit is contained in:
parent
9258d74afa
commit
b744d8e6ee
|
@ -12,6 +12,15 @@
|
|||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<jacoco.version>0.8.6</jacoco.version>
|
||||
<system-rules.version>1.19.0</system-rules.version>
|
||||
<system-lambda.version>1.0.0</system-lambda.version>
|
||||
<system-stubs.version>1.1.0</system-stubs.version>
|
||||
<junit.jupiter.version>5.6.2</junit.jupiter.version>
|
||||
<assertj-core.version>3.16.1</assertj-core.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
|
@ -72,6 +81,36 @@
|
|||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Plugins for JACOCO Coverage report -->
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>${jacoco.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>jacoco-initialize</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>jacoco-site</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>testing-libraries</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
|
@ -81,11 +120,5 @@
|
|||
</resources>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<system-rules.version>1.19.0</system-rules.version>
|
||||
<system-lambda.version>1.0.0</system-lambda.version>
|
||||
<system-stubs.version>1.1.0</system-stubs.version>
|
||||
<junit.jupiter.version>5.6.2</junit.jupiter.version>
|
||||
<assertj-core.version>3.16.1</assertj-core.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package com.baeldung.sonarqubeandjacoco.product;
|
||||
|
||||
public class Product {
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private int units;
|
||||
private double price;
|
||||
|
||||
public Product() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Product(int id, String name, int units, double price) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.units = units;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getUnits() {
|
||||
return units;
|
||||
}
|
||||
|
||||
public void setUnits(int units) {
|
||||
this.units = units;
|
||||
}
|
||||
|
||||
public double getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(double price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.baeldung.sonarqubeandjacoco.product;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.sonarqubeandjacoco.product.Product;
|
||||
|
||||
public class ProductUnitTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
Product product = new Product();
|
||||
product.setId(1);
|
||||
assertNull(product.getName());
|
||||
assert (product.getId() == 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProduct() {
|
||||
Product product = new Product(1, "product", 1, 2.0);
|
||||
assertNotNull(product.getName());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue