问题
I am using nightwatch.js and browser stack and am running a series of test functions that look like below; that run through my application from login point to deeper actions.
i.e.
this.TeamPanel = function(browser) {
browser
.url(Data.urls.oppListing)
.waitForElementVisible("div#team.btn-icon", 1000)
.click("div#team.btn-icon")
.waitForElementVisible("div.side-panel.open", 1000)
// .waitForElementVisible("div.box.team-member-summary-wrap.editable.fade-enter-done", 1000)
// .waitForElementVisible("input#input", 1000)
// .click("div#team.btn-icon")
.waitForElementVisible("div.button", 1000)
.click("div.button")
Errors.checkForErrors(browser);
browser.end();
};
I am wondering how to incorporate 'parallel' testing; to have my functions report as separate tests as opposed to one huge test.
I've tried wrapping the below around my functions with no luck: '
module.exports = {
};
回答1:
If you are using sample nightWatch-browserstack project, to modulate your tests, you need to split your test functions and place them in seperate .js files and put the file either under 'single' folder or 'suite' folder. If your test functions are dependent on other functions say login, then ensure you add the 'login' function in other files too. I have created a sample project tweaking the above project here. If you look into the single folder, you will find two .js files named 'TestCase1.js' and 'TestCase2.js' which are two separate test functions. Similarly, add your tests functions to either of 'single' or 'suite' folders. The significance of 'single' folder is all the functions under 'single' folder will be executed in sequential fashion ie one after the other. Whereas the functions under the 'suite' folder will be executed in parallel fashion.
来源:https://stackoverflow.com/questions/52062689/how-to-modulate-my-functions-as-seperate-parallel-tests