How to run nightwatch.js tests in parallel? - testing

I came across this question:
How can I run multiple tests in parallel with JS/nightwatchjs?
But I want to execute multiple tests in parallel in the chrome browser only, in multiple chrome driver sessions.
I am used to java-testng-selenium based test suites where I can specify in the testng.xml file that I want to run multiple test classes or test methods in parallel and the framework does that exactly. If I specify in testng.xml that I want multiple test methods to execute in parallel in 4 threads, 4 chrome browser sessions pop-up and 4 test methods are executed in parallel.
Here's an example with a thread-count=2: https://github.com/adityai/testng-parallelsample/blob/master/methods-test-testng.xml
How can I do the same with nightwatch.js?

You might want to try the test_workers configuration, although I haven't tried it myself it should do exactly what you are looking for.
And a nice article that demostrates it in action:
https://markus.oberlehner.net/blog/speeding-up-nightwatch-powered-acceptance-tests/

Related

How to run TestCafe tests in parallel in CI by specifying the metadata

As far as I know TestCafe default behaviour is to run tests in parallel.
Indeed the browsers function accepts an array of browser (which is cool).
What I would like to do however is quite different. I have fixtures based on area of my portal (search, payment etc...) and so I'd like to know if it's possible to run these tests in CLI in parallel as they are orthogonal.
The scope is of course to improve the execution time as the number test
cases will grow.
On the other hand I'd like also to catch the failures meaning that if a test ran in parallel on a specific metadata filter fails possibly we would like to stop the others too.
I am not using TestCafe's docker but our custom one with just Firefox, Chrome installed and we launch of tests in headless mode.
As a last point a great thing would be if we could run these scenario/metadata in parallel but somehow at the end of the test suite gather the reports together.
I understand the question is not easy especially because it involves either TestCafe or GitlabCi but probably someone else faced this problem too.
Thank you
If I understand you correctly, the behavior you described can be achieved by dividing the test execution among multiple CI jobs. For example, each CI job can test a particular area of your portal. For that, run TestCafe with specified metadata of your fixture/test. Also, most of the CI systems allow you to cancel all other jobs in a pipeline if one of the jobs fails (unfortunately, Gitlab hasn't released this feature yet).
On the other hand, you can use TestCafe's programmatic API: create multiple TestCafe runners, each running the desired subset of tests. However, at the end of the test execution, you'll need to merge generated reports into one report manually. Check this answer to get an idea of how to create multiple runners.

Is it possible to run multiple tests in parallel on same browser (IE) using Selenium Grid?

I have a selenium java code which executes tests on IE. I want to try executing these tests in parallel using the same browser. How can I achieve this? And will I need to use multiple nodes to do so?
You need to setup a selenium grid which has atleast 2 nodes attached to it.
When it comes to IE support, you can run ONLY 1 test at any given point in time on one selenium node.
So if you need to run two parallel IE tests, then you would need to have atleast 2 nodes attached to your grid.
This blog post of mine gives you a complete overview of the selenium grid.
https://rationaleemotions.github.io/gridopadesham/

Forcing integration tests to run one at a time in a jenkins pipeline

I have a small collection of integration tests that utilize selenium in a class. The idea is that these tests run every time there is a merge to the codebase, with the merge proceeding through the pipeline and having a series of tests running against the new code.
The thing is, these selenium tests have to run one at a time. They're using the browser to log into a website, and the account will just log out if more than one person tries to log into the account at once, it'll just log out, and the test will obviously fail, so I need these tests to run one at a time. I've tried using the #NotThreadSafe annotation, doesn't seem to have changed anything, and I've searched through for some sort of switch or parameter that defines how many tests run at once with no luck. These tests are using junit 4.12.

Running the same junit test case using selenium webdriver in multiple instances of the same browser (load testing)

I'm trying to simulate a firefox load testing situation. I want my to test how 10 simultaneous logins would play out on my system. I already have a connected selenium grid hub and 10 open nodes.
So far, I know I can write the test case and run it 10 times which isn't what I need because it isn't automated. I also know that I can use invocation count on the test to make it run as many times as i want but this only works on the same browser node.
Does anyone have any ideas on how to automatically distribute the same test case to multiple instances of the same driver profile?
i.e. Run a login case test times on the same firefox profile open in 10 different nodes in parallel.
Gracias!
P.S. I built my tests using testNG if that matters.
Basically selenium and testNG is not for such requiurement. You should use some dedicated tool for that like jmeter.
However you can run n methods parrallel let say if you want to login with 10 dif user in 10 thread/browser you can create test data driven and configure to run method in parrallel. Make sure you are providing proper value of parrallel thread count.
How about combining threadpoolsize with invocationcount. - http://testng.org/doc/documentation-main.html#parallel-running
Grid would take care to distribute on the 10 nodes.
use headless browser like GHOST and then invoke multiple threads as ghost has no UI so it would work in your case

Running Selenium Tests in Parallel

I have selenium test that takes 1 minute to complete . If I want to run this 1000 times I have to wait 16 hours . Is there any way I can run 5 tests in parallel so that it can be done in 3 hours ? I have generated a JUnit test scrip and tried to run in with multiple threads but they end up using the same Firefox window . I don't want to run this on grid cause running 5 Firefox window is not that resource intensive.
Thanks
By using below logic you can run your junit cases in parallel.
Class[] cls={test1.class,test2.class,test3.class,test4.class};
JUnitCore.runClasses(new ParallelComputer(true,false),cls);
In above method first parameter of ParallelComputer() indicates classes and second one is for methods. Here I'm running classes in parallel but not methods.
ParallelComputer Class documentation
http://junit-team.github.io/junit/javadoc/4.10/org/junit/experimental/ParallelComputer.html
Try with this example
http://mycila.googlecode.com/svn/sandbox/src/main/java/com/mycila/sandbox/junit/runner/
The file to launch is MySuite.java. Works well for me.