diff --git a/.github/workflows/pull-request_validation.yml b/.github/workflows/pull-request_validation.yml
index e8b1245..856faec 100644
--- a/.github/workflows/pull-request_validation.yml
+++ b/.github/workflows/pull-request_validation.yml
@@ -72,10 +72,20 @@ jobs:
echo "::set-output name=classes::$( echo $classes | sed 's/\(.*\),/\1 /' )"
# Run Apex tests in scratch org
- # TODO throw error on below 75% code coverage
- name: "Run Apex tests"
run: "sfdx force:apex:test:run -t ${{ steps.test-classes-in-repo.outputs.classes }} -c -r human -d ./tests/apex -w 20"
+ # Validate at least 85% code coverage
+ - name: Validate at least 85% code coverage
+ run:
+ codecoverage=$(cat tests/apex/test-result-7*.json | jq '.summary.testRunCoverage' | sed 's/\"//g; s/\%//g')
+ if [ $codecoverage -lt 85 ]
+ then
+ echo "Code coverage: $codecoverage%"
+ echo "Because it is less than 85%, the validation failed"
+ exit 125
+ fi
+
# Delete scratch orgs
- name: "Delete scratch org"
if: always()
diff --git a/force-app/main/default/classes/testclass2.cls b/force-app/main/default/classes/testclass2.cls
new file mode 100644
index 0000000..0c7c9c6
--- /dev/null
+++ b/force-app/main/default/classes/testclass2.cls
@@ -0,0 +1,11 @@
+public with sharing class testclass2 {
+ public static Boolean testFunc() {
+ System.debug('test');
+ return true;
+ }
+ }
+
+
+
+
+
\ No newline at end of file
diff --git a/force-app/main/default/classes/testclass2.cls-meta.xml b/force-app/main/default/classes/testclass2.cls-meta.xml
new file mode 100644
index 0000000..8e4d11f
--- /dev/null
+++ b/force-app/main/default/classes/testclass2.cls-meta.xml
@@ -0,0 +1,5 @@
+
+
+ 49.0
+ Active
+
diff --git a/force-app/main/default/classes/testclass2test.cls b/force-app/main/default/classes/testclass2test.cls
new file mode 100644
index 0000000..9109f41
--- /dev/null
+++ b/force-app/main/default/classes/testclass2test.cls
@@ -0,0 +1,7 @@
+@isTest
+private without sharing class testclass2test {
+ @isTest
+ private static void testFunction() {
+ System.assert(testclass2.testFunc(), 'should be true');
+ }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/testclass2test.cls-meta.xml b/force-app/main/default/classes/testclass2test.cls-meta.xml
new file mode 100644
index 0000000..8e4d11f
--- /dev/null
+++ b/force-app/main/default/classes/testclass2test.cls-meta.xml
@@ -0,0 +1,5 @@
+
+
+ 49.0
+ Active
+