setup_file and setup does find few issues, may be improve my understanding. #1022
Replies: 3 comments
-
The tests run in a subshell of setup_file for test isolation reasons. This means, that only exported variables and functions are visible from setup_file to test. |
Beta Was this translation helpful? Give feedback.
-
Could it be that the documentation is incorrect in this case? The tutorial section says the following: setup_file() {
load 'test_helper/common-setup'
_common_setup
PORT=$(project.sh start-echo-server 2>&1 >/dev/null)
export PORT
}
@test "server is reachable" {
nc -z localhost "$PORT"
} And _common_setup() {
load 'test_helper/bats-support/load'
load 'test_helper/bats-assert/load'
# get the containing directory of this file
# use $BATS_TEST_FILENAME instead of ${BASH_SOURCE[0]} or $0,
# as those will point to the bats executable's location or the preprocessed file respectively
PROJECT_ROOT="$( cd "$( dirname "$BATS_TEST_FILENAME" )/.." >/dev/null 2>&1 && pwd )"
# make executables in src/ visible to PATH
PATH="$PROJECT_ROOT/src:$PATH"
} I would therefore assume that it is ok and intended to load the libraries in the |
Beta Was this translation helpful? Give feedback.
-
The tutorial is misleading in this case. The main task of |
Beta Was this translation helpful? Give feedback.
-
I'm working on bats and have couple of issues.
assume one.batsas my bats file.
If i move
it actually fails.... any idea?
Beta Was this translation helpful? Give feedback.
All reactions