-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
When I attempt to run a test with a stub, the test runner gets stuck without throwing an error. It must be exited with CTRL + C
$ find -type f | entr ./node_modules/bats/bin/bats -r ./helpers/tests
✓ a/b matcher to ensure the asserts are working
✓ createConfigFile
✓ toLowercase
gatherConfigOptions 4/4
I need to stub read
to allow automated testing to work. But this code is causing the halt:
# tests.bats
load "batsMock/stub" # saved via git submodule into this folder
@test "gatherConfigOptions" {
# setup
stub read \
"echo 'returnValue1'" \
"echo 'returnValue2'"
# test execution & assert
local options=$(gatherConfigOptions)
assert_equal $options "wrongValue"
# teardown
unstub read
}
Also tried
- Commenting out the
unstub
statement. No effect
I suspect that read
is running unstubbed and causing the infinite delay. I could be wrong though.
Anyone able to tell what the issue is and how to overcome it?
Here is the function I am attempting to stub the internals of:
# ./helpers/helpers.sh
function gatherConfigOptions {
declare -A configData
read -p "prompt text here" "configData[languageCode]"
read -p "prompt text here" "configData[numberOfRepeats]"
echo "${configData[*]}"
}
Metadata
Metadata
Assignees
Labels
No labels