Splitting PHPUnit tests for a Laravel app

parallelism

#1

Trying to get tests running in parallel. so far i have tests running in 2 containers. However, it’s only running a few tests in each container. i’ve got ~390 tests but seeing only ~65 actually being ran.

Double checked I was getting the correct files with the circleci tests glob. Just ran the following locally to assert i had the files and found the expected 99 files.

circleci tests glob ./tests/**/*.php | wc -l

Here’s the what i’ve got so far.

TESTFILES=$(circleci tests glob ./tests/**/*.php | circlec tests split) 

for x in ${TESTFILES};do cp --parents $x ./temp; done

./vendor/bin/phpunit ./temp 

If i up the parallelism to 3 or more i get a few more tests to run but it appears i’d have to add more than the 8 containers i have to accomplish running all the tests.

Am i just missing something here?


#2

I got this working.

was simply an issue with the glob in ci vs locally. :man_facepalming:


#3

I’d be interested to know how this works. Is circleci a command available remotely in the build machines?


#4

Yes it is. You can find more about it here https://circleci.com/docs/2.0/parallelism-faster-jobs/#using-the-circleci-cli-to-split-tests

It’s the CLI, which is documented here https://circleci.com/docs/2.0/local-cli/


#5

I guess a plain Docker image is spun up, and then the executable is docker cped into /bin/, something like that? I always thought this was local only, since it isn’t available on images (except circleci ones, of course).


#6

I’m pretty sure it’s injected into all images. Do you not see it there when you try to run it? We may need to update our docs to be clearer.


#7

I’ve not tried it, in fact - probably because I thought it was local only. I will give it a go some time!