You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/bin/bash
function Outer
{
echo "outer"
function Inner
{
echo "Inner"
}
Inner
}
Outer_spec.sh
Describe 'Outer'
Include common/Outer.sh
Describe 'Test Inner Function Call'
It 'call Outer'
When call Outer
The output should equal "outer
Inner"
End
It 'call Inner'
When call Inner
The output should equal "Inner"
End
End
End
Upon executing
_Running: /bin/sh [bash 4.2.46(2)-release]
..F
Examples:
Outer Test Inner Function Call call Inner
When call Inner
1.1) The output should equal Inner
expected: "Inner"
got: ""
# spec/Outer_spec.sh:11
1.2) WARNING: It exits with status non-zero but not found expectation
status:127
# spec/Outer_spec.sh:9-12
1.3) WARNING: There was output to stderr but not found expectation
stderr:/usr/local/lib/shellspec/lib/core/evaluation.sh: line 158: Inner: command not found
# spec/Outer_spec.sh:9-12
Failure examples / Errors: (Listed here affect your suite's status)
shellspec spec/Outer_spec.sh:9 # 1) Outer Test Inner Function Call call Inner FAILED
Aborted with status code [executor: 0] [reporter: 1] [error handler: 0]
Fatal error occurred, terminated with exit status 1._
In the actual scenarios there are many inner functions and many more processing happens in the Outer(). Hence is not advisable to call Outer function everytime for an inner function.
Kindly help to write testcases for the inner functions
The text was updated successfully, but these errors were encountered:
Hello @emiljoshva. Why don't you define Inner outside Outer? With your choice, Inner is not directly testable, hence you'll need to run Outer for every Inner test. You could define a setup function and then test Inner if you really need it like this.
# Code not tested
Describe 'Inner'
Include common/Outer.sh
setup() {
Outer >> /dev/null # define Inner
}
It 'call Inner'
setup
When call Inner
The output should equal "Inner"
End
End
But maybe you'll need to deal with contexts (I call it context swamp of ShellSpec, the contexts are too confusing to understand at first).
Outer.sh
Outer_spec.sh
Upon executing
_Running: /bin/sh [bash 4.2.46(2)-release]
..F
Examples:
Outer Test Inner Function Call call Inner
When call Inner
1.1) The output should equal Inner
1.2) WARNING: It exits with status non-zero but not found expectation
1.3) WARNING: There was output to stderr but not found expectation
Finished in 0.26 seconds (user 0.23 seconds, sys 0.05 seconds)
3 examples, 1 failure
Failure examples / Errors: (Listed here affect your suite's status)
shellspec spec/Outer_spec.sh:9 # 1) Outer Test Inner Function Call call Inner FAILED
Aborted with status code [executor: 0] [reporter: 1] [error handler: 0]
Fatal error occurred, terminated with exit status 1._
In the actual scenarios there are many inner functions and many more processing happens in the Outer(). Hence is not advisable to call Outer function everytime for an inner function.
Kindly help to write testcases for the inner functions
The text was updated successfully, but these errors were encountered: