-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parallel Suites #849
Parallel Suites #849
Conversation
Any exceptions that are thrown in an asynchronous test are assigned to the very first runnable item, this change would force everyone to catch their assertion errors and pass them to done manually. |
You are right, this is an oversight on my part -- it didn't show up in my testing. This can be solved by using domains, but then mocha will not run properly in the browser. My fork of mocha would be Node-only, or require explicit passing of the error to done(). |
Also just ran into an issue where mocha no longer exits with a non zero on test failure. Seems to be related to nested Runners but haven't dug very deep just yet. |
I will try to fix these additional issues before the end of tomorrow. I think I will have suites always run in series in the browser regardless of the flag, since there is no way to add domain-like behavior. |
The more I think about this the more I feel like defining a suite as parallel should impact how it is run with its siblings and not how its children are run. Going that way would also fix a bug where if you set a suite without children suites as parallel the whole thing fails to output anything of use and hangs. |
What do you propose the UI should look like exactly? Either way, the parent suite will have to know what to run in parallel and what in series. |
sorry :( I dont want to go down that road with mocha, "expresso" was fully parallel before and it causes nothing but issues, and in many cases it's not any faster, in most of my experience it usually results in slower tests (depending on case of course) due to thrashing of various kinds. Consistency and predictability is definitely preferred here over slight performance gains. Some people might be interested in a fork though I'm not sure |
OK, that is fine. I will probably continue to maintain the fork, as I'm using it pretty heavily on a project. |
FYI, I am finding that domains are not adequate to handle all asynchronous errors. See nodejs/node-v0.x-archive#3908 It's frustrating, because I cannot create a simple test case that reproduces the error I get when running a complicated suite. All the node core methods are fairly fastidious about binding their callbacks to the current domain. I'm going to investigate using separate processes, but in the meantime, parallelism is better achieved outside of mocha itself. |
@aearly, there is a "Parallel Mocha" project, https://github.com/atsuya/parallel-mocha I have not tried it yet, but I'm also interested in the concept. There's a test runner for Perl called |
I ended with doing a mocha compatible project that supports both promises and parallelization if anyone is interested. There are some concurrency controls and neat reporters to show how things are scheduled and ran when you run into issues. |
Interesting, I'll have to check it out. I see you're using domains for Anything is likely better than the multi-process frankenstein monster I On Mon, Apr 14, 2014 at 2:29 PM, Nathan Brown [email protected]:
|
probably not modularizing your projects much if the tests are that slow :p the original expresso test runner was parallel but it just causes far more issues than you gain, but it's easy to parallelize via modularity and CI |
Well, if each suite launches a functional test on a Sauce Labs browser, On Mon, Apr 14, 2014 at 3:17 PM, TJ Holowaychuk [email protected]:
|
Certainly agree for unit testing @visionmedia. Our issues with serialized tests were based around full suite functional testing. Only a few tests needed to run in isolation while the rest could be parallelized. Using CI to solve it would have caused us to engineer mutexes outside of the test runner. Fun experiment either way. |
I agree as well, all our unit & integration tests run in matters of seconds. We do have one specific test suite though that would benefit from parallel tests: This test suite crawls our API using hypermedia & makes assertion on data integrity. This means making HTTP calls, discovering other related links to crawl, and creating new I understand however that it would add complexity / instability to Mocha, so we might look at other ways. It's probably going to be tricky since the tests are created dynamically, so we'd need the actual test runner to keep track of which ones have been run & which ones are left in the queue. Maybe if Mocha allows using a custom tests runner (similar to custom reporters) we might be able to look into providing a 3rd party runner? |
This feature allows you to specify that a suite's child suites will be run in parallel. Here is a code example:
I realize that this might be a bit out of scope for mocha, as it goes against some of the design decisions made in the past. But, nonetheless I had a use case for parallelism, I didn't want to abandon the other features of mocha, and there is some demand for parallelism from others, so I patched it in. This is related to issues #3, #19, #81, #98, #235, #309
Doing it at the Suite level seemed to be the most logical way to do it. Tests within a suite are still run in series. Here's a high level overview of the changes:
Runner
s to wrap only a single suite, create childRunner
s for childSuite
s, inheriting the proper properties along the way (globals, bailing, etc....)parallel
property toSuite
Runner
'sSuite
is parallel, run childRunner
s in parallel, otherwise run in seriesRunner
proxy events from childRunner
s, re-emit them immediately if running in series, or batching them if in parallel, replaying the sequence at the end. This prevents jumbled and interleaved reporting--parallel
CLI flag to run all root-level suites in parallel, if you want.This also encompasses my previous pull request, #836.