-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat(config): Add shardTestSuites config option #2633
feat(config): Add shardTestSuites config option #2633
Conversation
Nice feature. I am also looking for it. |
@@ -46,8 +46,8 @@ var TaskScheduler = function(config) { | |||
var capabilitiesSpecExcludes = ConfigParser.resolveFilePatterns( | |||
capabilities.exclude, true, config.configDir); | |||
capabilitiesSpecs = ConfigParser.resolveFilePatterns( | |||
capabilitiesSpecs).filter(function(path) { | |||
return capabilitiesSpecExcludes.indexOf(path) < 0; | |||
capabilitiesSpecs).filter(function (path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this space? It keeps things in-line with the rest of the project.
This is really interesting. Personally the need for having specs depend on one another feels like a smell, but I do understand need to be pragmatic about setting up state in large applications. I made some minor stylistic notes but i'll defer judgement to people who know/care more about this feature than I. To any of the maintainers, please let me know if my comments/feedback is not wanted; my desire is to be helpful, but I understand that it might be distracting or unnecessary :) |
suites: { | ||
okspec: 'suites/ok_spec.js', | ||
okmany: ['suites/ok_spec.js', 'suites/ok_2_spec.js'], | ||
failingtest: 'suites/always_fail_spec.js' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't think cause scripts/test.js
to fail?
@NickTomlin This is really handy for example for CRUD operations. @sjelin Added test to ensure that it's running on same |
@juliemr Thanks for your feedback @ AngularConnect in London. |
Thanks for the test updates! But you still need to add a test making sure that different suites are being run independently of each other (i.e. that your feature works). |
@@ -59,6 +60,17 @@ var TaskScheduler = function(config) { | |||
capabilitiesSpecs.forEach(function(spec) { | |||
specLists.push([spec]); | |||
}); | |||
} else if (capabilities.shardTestSuites){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document this in docs/referenceConf.js.
Can you provide an example where you must have tests that depend on each other? It is usually a bad practice when this happens, and I don't think we should encourage this by adding a feature to support interfile dependency in the core library. However, you may prove me wrong with a good example. |
@hankduan the example I have is from the company where I am currently working where the tests are taking in average 45min to run each build on a large AWS instance. Some context:
I don't want to get into specific details, but for example:
In this example:
It gets a bit more complicated, but I think this is a good example. We also did some effort to enable to run each suite of tests (modules) independently, this would allow us to run them in parallel. I've noticed you already support to run tests in x number of browser instances. @sjelin about the tests: I've created a really simple example where I navigate into one page on first spec file Ps: sorry for my delay on my reply. Let me know if you need anything else. |
I'll use your item tests as an example: test/e2e/campaign
- TestCreateItemFeature.js
- TestListItemFeature.js
- TestUpdateItemFeature.js I would highly suggest reorganizing the tests in one of the following ways: TestCreateItemFeature.js: describe('create item', function() {
it('creation test 1', testFunction1())
it('creation test 2', testFunction2())
it('creation test 3', testFunction3())
}); TestListItemFeature.js: describe('list item', function() {
beforeEach(function() {
// create your items;
});
it('list test 1', testFunction1())
it('list test 2', testFunction2())
afterEach(function() {
// delete your items;
});
}); TestUpdateItemFeature.js: describe('update item', function() {
beforeEach(function() {
// create your items;
});
it('update test 1', testFunction1())
it('update test 2', testFunction2())
afterEach(function() {
// delete your items;
});
}); So yes, this requires you to create and delete your items multiple times, but you will definitely run into issues if your tests start depending on each other. e.g.
Lastly, by no means do I intend for you to have no dependency on different files. My point is for you to not have dependencies on different tests. back to the example above, I could have a CreateItemPage.js page object. var createItemPage = {
goToPage: function () {
browser.get('...')
}
createItem: function (...params) {
$(...).sendKeys(param1);
$(...).sendKeys(param2);
$(...).sendKeys(param3);
$(...).click();
}
} TestCreateItemFeature.js: describe('create item', function() {
it('creation test 1', function() {
createItemPage.createItem('foo', 'bar', 34, 454);
// assert...
})
it('creation test 2', testFunction2())
it('creation test 3', testFunction3())
}); TestListItemFeature.js: describe('list item', function() {
beforeEach(function() {
// create your items;
createItemPage.createItem('item1', 'bar', 34, 454);
createItemPage.createItem('item2', 'bar', 34, 34);
});
it('list test 1', testFunction1())
it('list test 2', testFunction2())
afterEach(function() {
// delete your items;
});
}); TestUpdateItemFeature.js: describe('update item', function() {
beforeEach(function() {
// create your items;
createItemPage.createItem('item1', 'bar', 34, 454);
createItemPage.createItem('item2', 'bar', 34, 34);
});
it('update test 1', testFunction1())
it('update test 2', testFunction2())
afterEach(function() {
// delete your items;
});
}); |
@BernardoSilva You've got a great test for "Don't shard when I don't tell you to." But you also need a test for "Do shard when do I tell you to." |
Good feature 👍 |
Hello, any updates on this? @hankduan I also have a example why this would be great to have: I'm working on E2E's for booking system where the user can actually buy tickets for rail and it's a complicated process because it's divided into steps where each step can be only accessed after previous one has been completed. To add a cherry on the top - on some steps we're calling external services that return data required for that step to be completed so using the |
I'm cleaning up stale PRs and features, and closing this one. Please open a new PR/issue if you feel it's still valid. Thanks! |
@juliemr Please suggest when 'shardTestSuites' can be used. What changes will be required in spec file since I want to execute individual it blocks in parallel? Thanks in advance! |
Currently the option
shardTestFiles
makes the tests run in parallel but by file, if we have tests that have some dependency on the previous one then this approach does not work.shardTestSuites
option will allow to run tests in different instances but grouped bysuite
.The main goal of this feature is to reduce the time it takes to run tests on big applications that already have tests grouped by
suites
.I am still testing this approach, but would be nice to have more feedback.
There is an example of how I am using this feature.
example to run your suites in two instances: