Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/tests-report-on-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Tests Report

on: pull_request

jobs:
generate:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up JDK 21
uses: actions/setup-java@v1
with:
java-version: '10'

- name: Compile
run: mvn install -DskipTests

- name: Generate unit tests report
run: |
mvn pitest:mutationCoverage > mutation_output.txt 2>&1

LINE_COVERAGE=$(grep ">> Line Coverage" "mutation_output.txt" | sed -n 's/.*: \([0-9]\+\)\/\([0-9]\+\) (\([0-9]\+%\))/\1 \2 \3/p')
read -r COVERED TOTAL PERCENTAGE <<< "$LINE_COVERAGE"
MUTATION_COVERAGE=$(grep ">> Generated" "mutation_output.txt" | sed -n 's/.*Generated \([0-9]\+\) mutations Killed \([0-9]\+\) (\([0-9]\+%\))/\1 \2 \3/p')
read -r TOTAL_MUTATIONS KILLED PERCENTAGE_MUT <<< "$MUTATION_COVERAGE"

mkdir -p output
cat > output/mutations.md << EOF
## Tests report:
Excluding all \`infrastructure\` packages.
| Unit tests | Total | Covered | Percentage |
|---------------|------------------|----------|-----------------|
| **Lines** | $TOTAL | $COVERED | $PERCENTAGE |
| **Mutations** | $TOTAL_MUTATIONS | $KILLED | $PERCENTAGE_MUT |
EOF

rm mutation_output.txt

- name: Display unit tests report in PR's description
uses: zattoo/output@v1
with:
token: ${{github.token}}
sources: 'backend/output'
2 changes: 0 additions & 2 deletions src/test/java/com/example/ExampleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ void testModifyLargeList() {
assertEquals("Sesenta y cuatro", result.get(64));
}

/*
@Test
void testModifyEdgeCase() {
List<String> inputList = new ArrayList<>(Collections.nCopies(64, "Initial"));
List<String> result = Example.modify(inputList);

assertNull(result);
}
*/

}
Loading