You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-7Lines changed: 13 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ phpunit-randomizer
4
4
A PHPUnit extension that allows you to execute your test cases in a random order. This way you can identify tests that depend on other tests because they share some state, like object state, or even database state.
5
5
PHPUnit has an option to execute test cases in process isolation, but that takes a lot of time when you have many tests.
6
6
7
-
With this library, you don't have to modify any PHPUnit code. Just install it, and use the executable to run your tests, instead of using the default phpunit command.
7
+
With this library, you don't have to modify any PHPUnit code. Just install it, and use the binary from the vendor folder (vendor/fiunchinho/phpunit-randomizer/bin/phpunit-randomizer) to run your tests, instead of using the default phpunit command.
8
8
9
9
10
10
Installing Dependencies
@@ -17,21 +17,27 @@ $> php composer.phar install
17
17
18
18
Usage
19
19
-------
20
-
The executable binary is under the bin folder and it works exactly the same as the default phpunit file, accepting the same arguments, except for one: The `seed` argument.
20
+
The executable binary is under the bin folder and it works exactly the same as the default phpunit file, accepting the same arguments, except for one: The `order` argument.
21
21
22
22
```bash
23
23
$> bin/phpunit-randomizer -h
24
24
```
25
25
26
-
When you execute your tests using this library, if you look to the output, you'll see that it says that the tests have been randomized using a random seed. If you don't specify any seed, the seed will be calculated randomly, every time you execute your tests. But if you want to repeat an specific order that is interesting to you (because it failed, for example), you can re-run that order specifing the seed argument.
26
+
When you execute your tests using this library, you will get the same results as using a regular PHPUnit installation unless you use the `--order rand` parameter. Try executing the following:
27
27
28
-
For example, let's try to execute the example tests twice, and see how the order differ.
28
+
```bash
29
+
$> bin/phpunit-randomizer --order rand
30
+
```
31
+
32
+
If you look to the output, you'll see that it says that the tests have been randomized using a random seed. If you don't specify any seed (like the example above), the seed will be calculated randomly every time you execute your tests. But if you want to repeat an specific order that is interesting to you (because it failed, for example), you can re-run that order specifing the seed in your `order` argument.
33
+
34
+
For example, let's try to execute the example tests (that print the name of the test case so we can see the order in which they are executed) twice, and see how the order differ.
29
35
30
-

36
+

31
37
32
-
Here you can see how the order of the test cases is different in the two executions. Also, you can see the seed used in both cases (604 in the first one, 295 in the second). Now, if we want to repeat the order of the second execution, we can select the same seed.
38
+
Here you can see how the order of the test cases is different in the two executions. Also, you can see the seed used in both cases (8639 in the first one, 4674 in the second). Now, if we want to repeat the order of the second execution, we can select the same seed.
33
39
34
-

40
+

0 commit comments