gazard7's avatar

Run specific phpunit test group from elixir

Hi, does anyone know how to pass in options for phpUnit task in elixir, says if I just want to run a test group. I tried the code below in gulpfile.js but it still run all the tests.

elixir(mix => {
    mix.sass('app.scss')
       .webpack('app.js')
       .phpUnit({group: 'unit'});
});

Thanks in advance.

0 likes
2 replies
willvincent's avatar

I don't believe you can. However you are able to control what directory is used for tests, so if you group by directory you could change the target directory so that only tests in that directory (and it's sub-directories) are run..

So, assume you had a directory structure like this:

tests
  |
  +-- foo
  |
  +-- bar
       |
       +-- baz

by default tests in tests/foo, tests/bar and tests/bar/baz should all be run. If you only wanted the foo tests to run you could do something like this:

elixir.config.testing.phpUnit.path = 'tests/foo';

elixir( mix => {
  mix.phpUnit();
});
ejdelmonico's avatar
Level 53

As @willvincent said, the phpunit() method only runs the full suite of tests. You would have to write a specific task to do what you want.

import TestingTask from '../TestingTask';

/*
 |----------------------------------------------------------------
 | PHPUnit Testing
 |----------------------------------------------------------------
 |
 | This task will trigger your entire PHPUnit test suite and it
 | will show notifications indicating the success or failure
 | of that test suite. It works great with your tdd task.
 |
 */

Elixir.extend('phpUnit', function(src, command) {
    new TestingTask('phpUnit', src, command);
});

Please or to participate in this conversation.