I'd like to run multiple test files with a single report file (xunit). The catch is that I'd like to run shell/python scripts that re-configure my test bed in between the test file runs.
this works but without shell script
mocha script1.js script2.js -R xunit
I would like:
mocha script1 -R xunit
./myscript.sh
mocha script3 -R xunit
but I would like the output of script1 and script 2 to be a single report.
Mocha has good support for glob patterns, and in this case you should be able to do:
mocha ./script* -R xunit
Related
I have many test spec files with describe() and it(). Needs to run only some cases (it()) say that is sanity cases of each spec file. How to run all sanity cases of each describe() of all test spec files?
I am using Webdriverio and javascript.
There are two ways of doing it.
Create separate files for each type of tests and run them as per your needs.
You can utilize grep flag of mocha to tell mocha which test case to pick.
I would prefer second one as it is more extensible. Here is what you have to do:
Update summary of it blocks to include a pattern e.g. #sanity#regression etc
At the tile of running tests from command line, pass grep flag as
mocha -g "#sanity"
Mocha will check for the text passed in the command in each of the tests and will execute only the matching ones.
I'm using latest node, mocha to run UI tests and mochaawesome for reporting. I would like to get output of mocha test command in console output and text file both.
Test works fine but user can't see console output promptly if output is redirected and if i don't redirect then report text file is not created. mochawesome report doesn't create text file, default behavior is html file. I need both kind of output, any alternative using mochawesome report or any other solution to have this facility?
config:
npm install mocha mochaawesome
report.txt:
mocha create-event.js -f Smoke > report.txt
console output:
mocha create-event.js -f Smoke
Please use tee command to view console output and redirecting output to file together. Please use powershell especially for windows (doesn't work via normal cmd) and bash/sh for linux.
mocha create-event.js -f Smoke | tee report.txt
I have a script that runs my Lua Unit Test. Each test has its own output of a summary. However, I want to count and see which test fail after all of the test are ran.
The script loops through the test like so:
# Loop over all the UTs and run them
for utLuaScript in `ls ut*.lua` ; do
echo "LAUNCH TEST: ${utLuaScript}"
lua ./${utLuaScript} -v
echo
done
What is the solution here? Have the number of successes and failure saved to file, then once outside of this loop, go through the file and summarize all of the test. Can the script spit out a variable? What is best practice?
The usual way this is done is with a test runner script. In this approach, the unit tests are not executable by themselves (i.e. lua ut_foo.lua doesn't do anything), but must be run through the test runner. For example, lua test_runner.lua might run all the tests, and lua test_runner.lua ut_foo.lua might run just the "ut_foo" tests. The test runner script takes care of formatting and displaying the test results.
There are quite a few test runners already available for Lua; see the overview on the Lua-users wiki. Perhaps one of those will meet your needs, or can be adapted to do so.
This seems simple but I can't find a reputable solution via Google or searching SO.
I'm using foreman with a Rails 4 app to load ENV via a .env file. To run my tests properly, I have to execute foreman run rspec [optional files].
This gets tedious and occasionally I forget the foreman run part. I'd like to override the rspec command for a single app so that:
rspec [files] => foreman start [files]
Looked at binstubs but I don't fully understand them and they don't look exactly like what I want.
I can create a bash script that does this, but now that's specific to my local machine instead of built into the app codebase.
I ended up creating a script in my ~/scripts folder (where I store my own scripts added to my PATH).
Here's what I have in ~/scripts/tester (with executable permissions):
#!/bin/bash
#==================================================
# Created: 2014-04-01 / Updated: 2014-04-01
# Desc: Shorten syntax to run tests properly.
#==================================================
# For developers who may not use bash at all...
# $0 = filename and path
# $1 = first arg...
cmd="foreman run rspec $1"
echo "#--------------------------------------------------"
echo "# EXECUTING: $0"
echo "# '$cmd'"
echo "#--------------------------------------------------"
$cmd
I can execute with tester in my rails app directory and it will run foreman run rspec which executes all tests or I can pass in specific files or wildcard-names and it will run the matched tests.
It outputs the file location so if I pass this script on to others they know what files being run so they can modify it...I do this because I've actually run into a situation where a new developer was Googling a "tester" script for rails wondering why he couldn't find it as part of core rails...this way newbies know exactly what's being run and where the file's located at.
Chose tester as the script name because it wouldn't clash with any other known commands AFAIK.
Sample input:
tester => foreman run rspec # all specs
tester spec/models => foreman run rspec spec/models # run all model specs
I'm using Ruby + Cucumber + Watir WebDriver to create functional tests for my web project. I've divided my scenarios by priorities using simple tags: #critical, #major, etc. I'm using Rake to run my features. I've created several tasks in my Rakefile.
Now I try to use parallel_tests gem to run my features in parallel mode. I've created special task 'parallel' in my Rakefile:
task :parallel do
'parallel_cucumber features -n 4'
end
My question is: can I parallel my features execution AND use tags at the same time (for example run parallel_cucumber only for "#critical" scenarios in features)?
You can create configuration called "parallel" in your cucumber.yml file and add all of the parameters from the other configurations (for example tags). After that you can run parallel_cucumber and it will use this configuration automatically.
You could try using the -o option. Try something like this:
parallel_cucumber features/ -n 4 -o '-r features -t #critical'
You can even use ENV['tags'] to read from the command line, and pass that to the above inside your task.