Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing coverage diff #23

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
16 changes: 9 additions & 7 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 17

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand All @@ -29,13 +29,15 @@ jobs:

- name: Jacoco Report to PR
id: jacoco
uses: madrapps/jacoco-report@v1.1
uses: madrapps/jacoco-report@style-title
with:
path: ${{ github.workspace }}/build/reports/jacoco/testCoverage/testCoverage.xml
paths: ${{ github.workspace }}/build/reports/jacoco/**/testCoverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 40
min-coverage-changed-files: 60
debug-mode: false
min-coverage-overall: 70
min-coverage-changed-files: 70
update-comment: true
title: '# :robot: `Coverage Report`'
debug-mode: true

- name: Get the Coverage info
run: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.madrapps.jacoco;

public class Utils {
public class Utility {

public int multiply(int a, int b) {
return a * b;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/madrapps/jacoco/operation/StringOp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

public class StringOp {

/**
* Adding some java doc
* @param source
* @param chars
* @return
*/
public boolean endsWith(String source, String chars) {
return source.endsWith(chars);
}

public boolean startsWith(String source, String chars) {
// Just adding some sample comment
return source.startsWith(chars);
}
}
23 changes: 20 additions & 3 deletions src/main/kotlin/com/madrapps/jacoco/Math.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,43 @@ package com.madrapps.jacoco
class Arithmetic {

fun add(a: Int, b: Int): Int {
if (a < b) {
// Do nothing
}
return a + b
}

fun subtract(a: Int, b: Int): Int {
return a - b
if (a > b) {
return a - b
} else {
return a - b
}
}

fun multiply(a: Int, b: Int): Int {
// Some comment here
return a * b
}

fun divide(a: Int, b: Int): Int {
return a / b
if (a > b) {
return a / b
} else {
return a / b
}
}

fun modulo(a: Int, b: Int): Int {
// Some comment for non-covered method
return a % b
}

fun area(a: Int, b: Int): Int {
return a * b
}
}

fun volume(a: Int, b: Int, c: Int): Int {
return a * b * c
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,18 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class UtilsTest {
public class UtilityTest {

@Test
public void testAdd() {
final Utils utils = new Utils();
final Utility utils = new Utility();
int actual = utils.add(2, 3);
Assertions.assertEquals(5, actual);
}

@Test
public void testSubtract() {
final Utils utils = new Utils();
int actual = utils.subtract(8, 3);
Assertions.assertEquals(5, actual);
}

@Test
public void testSquare() {
final Utils utils = new Utils();
final Utility utils = new Utility();
int actual = utils.square(3);
Assertions.assertEquals(9, actual);
}
Expand Down
7 changes: 0 additions & 7 deletions src/test/kotlin/com/madrapps/jacoco/MathTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ class MathTest {
Assertions.assertEquals(7, actual)
}

@Test
fun testSubtract() {
val math = Arithmetic()
val actual = math.subtract(8, 4)
Assertions.assertEquals(4, actual)
}

@Test
fun testMultiply() {
val math = Arithmetic()
Expand Down