how to modulate my functions as seperate parallel tests?

那年仲夏 提交于 2019-12-08 10:52:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!