Comments (10)
Yes, we should add this feature.
from bats.
As an extension to this pull request it may be useful to filter tests by name using a regexp or a glob-style expression.
from bats.
I'm currently using this: dougm@0b25d8a
With an Emacs mode to run the tests: https://github.com/dougm/bats-mode/blob/master/bats-mode.el
There's a key-binding to run a single bats test, wherever the cursor is currently at.
Any thoughts on the bats change above? Not sure the best way to do this, so I didn't mess with the options parser in bin/bats yet.
from bats.
Looks good and working to me.
I was initially thinking of a command-line option for bats, but environment variables are ok for me too.
from bats.
@ahippo I'd like a command-line option too, but afaict the options parser in bin/bats only handles boolean options. So I just wanted to get the concept working and check if I'm on the right path before making any changes to options parser.
from bats.
Yeah, you're right.
But at least adding a long option like --regex="qqq" seems pretty simple. (due to '=', it's a single argument)
Handling of --regex "qqq" or -r "qqq" requires much more changes though.
from bats.
@dougm This seems like a very useful feature. I hope it gets added soon. It would be cool to see a feature where BATS could do test grouping similar to TestNG.
from bats.
@harschware Just opened PR #117 - I've continued to use it myself as-is via bats-mode.el since
from bats.
Here is a simple shell script you can customize to run a single test:
$ cat one_test.sh
#!/bin/bash
batsdir=$(dirname $(readlink -f bats))
echo $batsdir
export PATH=$batsdir:$PATH
in=$1
a_test=$2
if [[ ! -e "$in" ]]
then
echo "not found: '$in'"
exit 2
fi
out=$(mktemp)
bats-preprocess < $in > $out
if [[ -z "$a_test" ]] || ! grep -q "^$a_test" $out
then
echo "test '$a_test' not found in $in"
echo "available test are:"
grep -o -E '^test_[^ ]+' $out
exit 1
fi
echo "temp_file: $out"
export BATS_TEST_SOURCE=$out
bats-exec-test $in $a_test
As you can see bats as already almost all for that, but you need to preprocess the file yourself, and pass the filename via export BATS_TEST_SOURCE
Not extensively tested…
list test available:
$ ./one_test.sh bats-preprocess.bats
/home/sylvain/code/bats/test/internal
test '' not found in bats-preprocess.bats
available test are:
test_preprocess_myself()
test_dummy_test()
run one by its encoded name
$ ./one_test.sh bats-preprocess.bats test_dummy_test
/home/sylvain/code/bats/test/internal
temp_file: /tmp/tmp.qJ5hM2Rl0O
1..1
ok 1 dummy test
enjoy.
from bats.
Thanks, @Sylvain303 ! One little fix: should be "readlink -f $(which bats)"
(at least it helped me run it in my env).
from bats.
Related Issues (20)
- Helpful test script HOT 2
- BATS libexec dir on install HOT 1
- Current release is out of date HOT 1
- automatically sourcing setup/teardown scripts? HOT 1
- How to use for & do loop based on if else condition.
- Support for JUNIT formatted output?
- Use bats-core HOT 1
- avoid `eval echo` with `encode_name` HOT 1
- Trying to test a curl request to an HTTP server using BATS. But as soon as it hits the run ./server it does not proceeds towards curl. This is because http server repeatedly listens for incoming requests. Any Ideas how can I tell BATS to go the next instruction (here curl) after it runs the server? HOT 1
- Update README to make it more clear we should be using bats-core HOT 3
- Sorry for the stupid question HOT 1
- Noskip option flag HOT 2
- `$cmd & echo foo | cat` freezes bats because pipe waits for backgrounded command to die HOT 3
- Document method for safely printing 'set -x' output in TAP mode HOT 1
- Show Why Tests Have Failed HOT 1
- Add bats_teardown_trap to existing EXIT trap instead of overwriting. HOT 1
- Is this project dead? Last commit over four years ago. HOT 2
- --formatter not recognized format
- Provide Link To Bats-Core HOT 3
- publish bats on https://open-vsx.org/
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bats.