diff --git phpunit.xml.dist phpunit.xml.dist
index 6297c52dc3..bf23114722 100644
--- phpunit.xml.dist
+++ phpunit.xml.dist
@@ -23,6 +23,7 @@
     <groups>
         <exclude>
             <group>ajax</group>
+            <group>factory</group>
             <group>ms-files</group>
             <group>ms-required</group>
             <group>external-http</group>
diff --git tests/phpunit/includes/bootstrap.php tests/phpunit/includes/bootstrap.php
index 5d3e159685..7337ea7efd 100644
--- tests/phpunit/includes/bootstrap.php
+++ tests/phpunit/includes/bootstrap.php
@@ -105,6 +105,7 @@ require_once ABSPATH . '/wp-settings.php';
 // Delete any default posts & related data
 _delete_all_posts();
 
+require dirname( __FILE__ ) . '/class-mock-passwordhash.php';
 require dirname( __FILE__ ) . '/testcase.php';
 require dirname( __FILE__ ) . '/testcase-rest-api.php';
 require dirname( __FILE__ ) . '/testcase-rest-controller.php';
diff --git tests/phpunit/includes/class-mock-passwordhash.php tests/phpunit/includes/class-mock-passwordhash.php
new file mode 100644
index 0000000000..320de7621c
--- /dev/null
+++ tests/phpunit/includes/class-mock-passwordhash.php
@@ -0,0 +1,16 @@
+<?php
+/**
+* Mock of the phpass class.
+*
+* @since 5.0.0
+*/
+
+/**
+* Class Mock_PasswordHash
+*/
+class Mock_PasswordHash {
+	// phpcs:disable WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid --- the mocked class does not use snake case.
+	function HashPassword( $password ) {
+		return $password;
+	}
+}
diff --git tests/phpunit/includes/factory/class-wp-unittest-factory-for-user.php tests/phpunit/includes/factory/class-wp-unittest-factory-for-user.php
index e2e2564b8c..6503a1e9e6 100644
--- tests/phpunit/includes/factory/class-wp-unittest-factory-for-user.php
+++ tests/phpunit/includes/factory/class-wp-unittest-factory-for-user.php
@@ -22,6 +22,20 @@ class WP_UnitTest_Factory_For_User extends WP_UnitTest_Factory_For_Thing {
 	}
 
 	function create_object( $args ) {
+		// Do not hash the user's password, use the mock hasher instead that returns the password in plain text.
+		if ( isset( $args['skip_password_hash'] ) && true === $args['skip_password_hash'] ) {
+			// phpcs:disable WordPress.Variables.GlobalVariables.OverrideProhibited --- overriding on purpose.
+			$GLOBALS['wp_hasher'] = new Mock_PasswordHash();
+
+			$user = wp_insert_user( $args );
+
+			// Unset the hasher global to ensure that the next call to `wp_hash_password()` creates a new instance, and
+			// everything works correctly.
+			unset( $GLOBALS['wp_hasher'] );
+
+			return $user;
+		}
+
 		return wp_insert_user( $args );
 	}
 
diff --git tests/phpunit/multisite.xml tests/phpunit/multisite.xml
index 0d60efbe1c..4ce0937a91 100644
--- tests/phpunit/multisite.xml
+++ tests/phpunit/multisite.xml
@@ -24,6 +24,7 @@
     <groups>
         <exclude>
             <group>ajax</group>
+            <group>factory</group>
             <group>ms-files</group>
             <group>ms-excluded</group>
             <group>external-http</group>
diff --git tests/phpunit/tests/factory/test-user.php tests/phpunit/tests/factory/test-user.php
new file mode 100644
index 0000000000..28c669fa0c
--- /dev/null
+++ tests/phpunit/tests/factory/test-user.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * Tests for the user fixture factory.
+ *
+ * @group factory
+ */
+class Tests_WP_UnitTest_Factory_For_User extends WP_UnitTestCase {
+	/**
+	 * Test that password hashing can be skipped when creating a user fixture, to improve performance.
+	 */
+	public function test_skip_password_hash() {
+		global $wpdb;
+
+		$user_id = self::factory()->user->create( array(
+			'skip_password_hash' => true,
+		) );
+
+		// Ensure that the password is stored as plain text.
+		$stored_password = $wpdb->get_var( $wpdb->prepare( "SELECT 'password' FROM $wpdb->users WHERE ID = %d", $user_id ) );
+		$this->assertSame( 'password', $stored_password );
+		// Ensure that the global variable containing the password hasher does not exist. This will ensure that
+		// `wp_hash_password()` creates a new instance, and everything works correctly.
+		$this->assertFalse( isset( $GLOBALS['wp_hasher'] ) );
+	}
+}
