nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.8k stars 1.32k forks source link

Nightwatch.js and execute whole test suite from folder #992

Closed kavimukh closed 8 years ago

kavimukh commented 8 years ago

Hi, OS: Windows Created few script in my test folder and while execution, it's executing in alphabetic order. To avoid this how I can specify my own order for nightwatch.js.

let's saying i have a.js, b.js, c.js and d.js in my test folder

During execution nightwatch.js is executing first a.js and b.js then c.js and the d.js

but I don't want in this order When I execute it should execute in following oder c.js b.js d.js a.js

and let's say I want to execute again c.js. Can I do then how?

AssadQ commented 8 years ago

Hi,

My understanding is that nightwatch runs the tests in the order they are in your directory. So, more often than not they'll run in alphabetical order.

If you have some tests which are set up tests (like, saving things into your database so that all your tests run in the same state of the app) then add a flag on them and call that flag before you run the other tests.

The other option is numbering the files like 1c.js 2b.js 3d.js 4a.js, but that isn't ideal. Especially if you want to insert a test between b and d.

But good practice would say that you shouldn't have tests that depend on other tests.. Not easy to do, but that is the ideal. Each test should tear_down to leave the app in the state it started in.

beatfactor commented 8 years ago

Yes, I also think that each test should be independent and so this feature is not something we will be adding, I'm afraid.

eric314 commented 7 years ago

Sometimes it is necessary to have dependent tests. In this case, it is in my experience easiest to consolidate all of this test code into a single test suite file. Use a linter and indenter to ensure your code is clean and readable.

Agreed that it is best whenever possible to conceptually create test suites (files) that are independent and create ("stand up") and clean up ("stand down") their own test data on their own.

Using environment variables to specify runtime information, such as login account information for test accounts, can be a useful tool in this process.