diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1b45b50..e8614d1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
All notable changes to `phpunit-watcher` will be documented in this file
+## Unreleased
+
+- new random seed feature. Run tests in random order.
+
## 1.11.2 - 2019-09-09
- Remove `deleteChar` call
diff --git a/src/Screens/Phpunit.php b/src/Screens/Phpunit.php
index 6e76b4d..9db4b5a 100644
--- a/src/Screens/Phpunit.php
+++ b/src/Screens/Phpunit.php
@@ -61,6 +61,9 @@ public function registerListeners()
case 'p':
$this->terminal->displayScreen(new FilterFileName());
break;
+ case 'r':
+ $this->terminal->displayScreen(new RandomSeed());
+ break;
case 'q':
die();
break;
@@ -114,6 +117,7 @@ protected function displayManual()
->write('Press p to filter by file name.')
->write('Press g to filter by group name.')
->write('Press s to filter by test suite name.')
+ ->write('Press r to run tests with a random seed.')
->write('Press q to quit the watcher.')
->write('Press Enter to trigger a test run.');
diff --git a/src/Screens/RandomSeed.php b/src/Screens/RandomSeed.php
new file mode 100644
index 0000000..cce24b1
--- /dev/null
+++ b/src/Screens/RandomSeed.php
@@ -0,0 +1,39 @@
+terminal
+ ->comment('Random seed usage')
+ ->write('Type a seed and press Enter to run tests in random order but with a specific seed.')
+ ->write('Press Enter with an empty pattern to execute all tests in random order.')
+ ->emptyLine()
+ ->comment('Start typing to add a random seed')
+ ->prompt('seed > ');
+
+ return $this;
+ }
+
+ public function registerListeners()
+ {
+ $this->terminal->on('data', function ($line) {
+ $phpunitArguments = '--order-by=random';
+ if ($line !== '') {
+ $phpunitArguments .= " --random-order-seed={$line}";
+ }
+
+ $phpunitScreen = $this->terminal->getPreviousScreen();
+
+ $options = $phpunitScreen->options;
+
+ $options['phpunit']['arguments'] = $phpunitArguments;
+
+ $this->terminal->displayScreen(new Phpunit($options));
+ });
+
+ return $this;
+ }
+}