diff --git a/.travis.yml b/.travis.yml
index 4ce1344c09..18f1306784 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,6 +18,8 @@ matrix:
     env: WP_TRAVISCI=travis:js
   - php: 7.3
   - php: 7.2
+  - php: 7.1
+    env: WP_TRAVISCI=travis:phpunit:coverage
   - php: 7.1
   - php: 7.0
     env: WP_TEST_REPORTER=true
@@ -36,7 +38,7 @@ matrix:
   - php: nightly
 before_install:
 - |
-  if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
+  if [[ "$WP_TRAVISCI" == travis:phpunit* ]]; then
       mysql -u root -e "CREATE DATABASE wordpress_tests;"
       cp wp-tests-config-sample.php wp-tests-config.php
       sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php
@@ -65,7 +67,7 @@ before_script:
   fi
 - |
   # Install the specified version of PHPUnit depending on the PHP version:
-  if [[ "$WP_TRAVISCI" == "travis:phpunit" ]]; then
+  if [[ "$WP_TRAVISCI" == travis:phpunit* ]]; then
     case "$TRAVIS_PHP_VERSION" in
       7.3|7.2|7.1|nightly)
         echo "Using PHPUnit 7.x"
@@ -123,6 +125,10 @@ after_script:
     export WPT_TEST_DIR=$(pwd)
     php test-runner/report.php
   fi
+- |
+  if [[ "$WP_TRAVISCI" == "travis:phpunit:coverage" ]]; then
+    bash <(curl -s https://codecov.io/bash)
+  fi
 notifications:
   slack:
     rooms:
diff --git a/Gruntfile.js b/Gruntfile.js
index a27fc2b735..e2ad76d53e 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -9,7 +9,7 @@ module.exports = function(grunt) {
 		spawn = require( 'child_process' ).spawnSync,
 		SOURCE_DIR = 'src/',
 		BUILD_DIR = 'build/',
-		WORKING_DIR = grunt.option( 'dev' ) ? SOURCE_DIR : BUILD_DIR,
+		WORKING_DIR = grunt.option( 'dev' ) || 'travis:phpunit:coverage' === grunt.cli.tasks[ 0 ] ? SOURCE_DIR : BUILD_DIR,
  		BANNER_TEXT = '/*! This file is auto-generated */',
 		autoprefixer = require( 'autoprefixer' ),
 		nodesass = require( 'node-sass' ),
@@ -662,6 +662,10 @@ module.exports = function(grunt) {
 			'restapi-jsclient': {
 				cmd: 'phpunit',
 				args: ['--verbose', '-c', 'phpunit.xml.dist', '--group', 'restapi-jsclient']
+			},
+			'coverage': {
+				cmd: 'phpdbg',
+				args: [ '-qrr', '/home/travis/.composer/vendor/bin/phpunit', '--verbose', '-c', 'phpunit.xml.dist', '--coverage-clover', 'coverage.xml' ]
 			}
 		},
 		uglify: {
@@ -1371,7 +1375,7 @@ module.exports = function(grunt) {
 	] );
 
 	grunt.registerTask( 'build', function() {
-		if ( grunt.option( 'dev' ) ) {
+		if ( grunt.option( 'dev' ) || 'travis:phpunit:coverage' === grunt.cli.tasks[ 0 ] ) {
 			grunt.task.run( [
 				'build:js',
 				'build:css',
@@ -1397,6 +1401,13 @@ module.exports = function(grunt) {
 
 	// Testing tasks.
 	grunt.registerMultiTask('phpunit', 'Runs PHPUnit tests, including the ajax, external-http, and multisite tests.', function() {
+		if ( 'travis:phpunit:coverage' === grunt.cli.tasks[ 0 ] ) {
+			grunt.util.spawn({
+				cmd: 'perl',
+				args: [ '-0777', '-pi', '-e', 's/\\s+<php>(.|\\n)*<\\/php>\\s//g', 'phpunit.xml.dist' ],
+				opts: {stdio: 'inherit'}
+			}, function () {} );
+		}
 		grunt.util.spawn({
 			cmd: this.data.cmd,
 			args: phpUnitWatchGroup ? this.data.args.concat( [ '--group', phpUnitWatchGroup ] ) : this.data.args,
@@ -1430,6 +1441,7 @@ module.exports = function(grunt) {
 	// Travis CI tasks.
 	grunt.registerTask('travis:js', 'Runs Javascript Travis CI tasks.', [ 'jshint:corejs', 'qunit:compiled' ]);
 	grunt.registerTask('travis:phpunit', 'Runs PHPUnit Travis CI tasks.', [ 'build', 'phpunit' ]);
+	grunt.registerTask('travis:phpunit:coverage', 'Runs PHPUnit Travis CI tasks.', [ 'build', 'phpunit:coverage' ]);
 	grunt.registerTask('travis:format', 'Runs Code formatting Travis CI tasks.', [ 'format:php:error' ]);
 
 	// Patch task.
