Merge pull request #14373 from ukhan1980/BAEL-6697-fail-maven-build-if-coverage-falls
[BAEL-6697] code for jacoco fail build
This commit is contained in:
commit
37510f10fd
|
@ -1,6 +1,6 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>testing-libraries-2</artifactId>
|
<artifactId>testing-libraries-2</artifactId>
|
||||||
<name>testing-libraries-2</name>
|
<name>testing-libraries-2</name>
|
||||||
|
@ -91,6 +91,32 @@
|
||||||
<goal>report</goal>
|
<goal>report</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>check-coverage</id>
|
||||||
|
<phase>verify</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<rules>
|
||||||
|
<rule>
|
||||||
|
<element>BUNDLE</element>
|
||||||
|
<limits>
|
||||||
|
<limit>
|
||||||
|
<counter>INSTRUCTION</counter>
|
||||||
|
<value>COVEREDRATIO</value>
|
||||||
|
<minimum>0.70</minimum>
|
||||||
|
</limit>
|
||||||
|
<limit>
|
||||||
|
<counter>BRANCH</counter>
|
||||||
|
<value>COVEREDRATIO</value>
|
||||||
|
<minimum>0.68</minimum>
|
||||||
|
</limit>
|
||||||
|
</limits>
|
||||||
|
</rule>
|
||||||
|
</rules>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|
|
@ -3,7 +3,13 @@ package com.baeldung.jacocoexclusions.service;
|
||||||
public class ProductService {
|
public class ProductService {
|
||||||
private static final double DISCOUNT = 0.25;
|
private static final double DISCOUNT = 0.25;
|
||||||
|
|
||||||
public double getSalePrice(double originalPrice) {
|
public double getSalePrice(double originalPrice, boolean flag) {
|
||||||
return originalPrice - originalPrice * DISCOUNT;
|
double discount;
|
||||||
|
if (flag) {
|
||||||
|
discount = originalPrice - originalPrice * DISCOUNT;
|
||||||
|
} else {
|
||||||
|
discount = originalPrice;
|
||||||
}
|
}
|
||||||
|
return discount;
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -9,7 +9,14 @@ class ProductServiceUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenOriginalPrice_whenGetSalePrice_thenReturnsDiscountedPrice() {
|
public void givenOriginalPrice_whenGetSalePrice_thenReturnsDiscountedPrice() {
|
||||||
ProductService productService = new ProductService();
|
ProductService productService = new ProductService();
|
||||||
double salePrice = productService.getSalePrice(100);
|
double salePrice = productService.getSalePrice(100, true);
|
||||||
assertEquals(salePrice, 75);
|
assertEquals(salePrice, 75);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenOriginalPrice_whenGetSalePriceWithFlagFalse_thenReturnsDiscountedPrice() {
|
||||||
|
ProductService productService = new ProductService();
|
||||||
|
double salePrice = productService.getSalePrice(100, false);
|
||||||
|
assertEquals(salePrice, 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue