Log which Test Executor is running particular test? - testing

I configured my tests to run in parallel:
In my build.gradle:
test{
maxParallelForks 2
forkEvery 0
}
./gradlew build --max-workers=8 --parallel
But additionally I would like to know which executor is running particular test.
Is it possible to log such information?
I've tried to use --debug option but I doesn't appear there.

the worker id is stored as system property and you can access it via within your test named System.getProperty('org.gradle.test.worker') from within your test.

Related

Is it possible to run all the tests using mocha even if there are some failures?

I am working on a node.js application and would like to know if there is a way I can run all the unit tests from all the sub modules even if there are some test failures to know how many tests are failing in total to start putting the fixes for them. We use mocha for our tests on the back-end and jest for the ui.
Thanks.
The default behavior for mocha is to run all the tests. If it is exiting after the first test failure, that would suggest that you are using the "bail" option typically enabled on the command line with either --bail or -b.
Relevant docs: https://mochajs.org/#-bail-b
It can also be caused by passing the option { bail: true } to mocha.setup(). Look in your test runner and in your package.json.
Lastly, the least likely of these possibilities is that it could also be caused by using this.bail() somewhere in the Mocha test runner.

How To Split TestCafe Tests?

We have around 400+ TestCafe js files and we are running these tests nightly through our CI/CD pipeline. Our problem right now is that, it consumes a lot of hours before it completes the test. What we are planning to do is to split up those tests maybe at least 4. Now my question is: How can we run the TestCafe in 4 instances with each instance runs the split tests?
For example:
Instance 1 - runs Tests #1 - #100
Instance 2 - runs Tests #101 - #200
Instance 3 - runs Tests #201 - #300
Instance 4 - runs Tests #301 - #400
You can use fixture or test metadata and hen execute a different command in each instance.
For example you use fixture metadata:
fixture `My fixture`
.meta('instance', '1')
// and somewhere else:
fixture `My fixture`
.meta('instance', '2')
then to run only tests within fixtures with a specific metadata:
$ testcafe chrome my-tests --fixture-meta instance=1
Or you can just group those fixture files in different directories and then run tests from only a specific directory:
$ testcafe chrome ./Tests/instance-one/*.js
I think I've found a solution to my own problem. I've installed this package called npm-run-all
I added the split tests in the package.json
"test:split1": "testcafe chromium src-compact/SplitTest1.js --skip-js-errors",
"test:split2": "testcafe chromium src-compact/SplitTest2.js --skip-js-errors",
"test:parallel": "npm-run-all -p test:split1 test:split2"
And then execute it by running this command:
npm run test:parallel

Execute TestNG.xml in dry run mode via eclipse

Is there a way to execute TestNG.xml in dry run mode so that I can figure out what methods gets qualified for the test run. I am using Eclipse and intend to run the tests via testng.xml. How to configure Run Configurations for this.
Newbie to Selenium-TestNG and Eclipse
I tried to provide -Dtestng.mode.dryrun=true in Run Configurations -> Arguments tab under both Program argument and VM arguments
The run configurations had no effect on the execution. The tests were executed in normal fashion. I expected the configurations would just list test methods in the console
You are going to see all tests with no failures. That what you expect when you run testNg with the argument.
To check the dryrun argument works, make your test to fail. Then run your test with "-Dtestng.mode.dryrun=true". Add the argument in "VM arguments"
Also, check your version of testNG is 6.14 or higher

Using Pytest to output only failures?

I'm trying to use Pytest.
How do I set flags such that all tests run, logs only to be output on failure on a per test basis while the test is running, and silent otherwise?
I don't want it to hold my test failure logs hostage while waiting for the entire test suite to finish.
You should use pytest-sugar pytest package. It gives test failure information and python traceback as soon as any test fails.
Install using pip install pytest-sugar and run the tests normally.
More info here: https://github.com/Frozenball/pytest-sugar
Edit: If you don't want to see the passing test logs, you can pass -rf argument. More info here: https://stackoverflow.com/a/55367504/2312300

Fail a Jenkins build when a Taurus-run JMeter test records a failure

I've got some tests setup to run via Taurus and kicking them off in a Jenkins stage like so:
...previous stages...
stage('Load Tests'){
dir('./tests'){
bat "bat _testFile.yml"
}
}
...stages to execute if Load Tests stage succeeds
I want to bail out of the whole build if any one of the iterations in any of my tests fails. But this setup, as well as wrapping in a try/catch don't work.
My fault. The fail criteria were not properly implemented. Now that they are, the above 'successfully' fails the jenkins build when the criteria are not met.