Open cades opened 8 years ago
Note: there is a same issue in rspec-given.
before
/ beforeEach
/ after
/ afterEach
if a setup needs to tear down, put it in before
instead of Given
.
Cleanup
, Afterwards
, Ensure
or Finally
// change this
Given server: -> Server.listen()
// to this
Given server:
setup: -> App.listen()
teardown: -> @server.close()
teardown
s are executed in reverse order compared to setup
s.setup
is executed, the corresponding teardown
is guaranteed to be executed no matter this test success or fail.setup
is not executed, the corresponding teardown
will not be executed.what if after
/ Cleanup
/ teardown
throws? should it fail the test or be silent ignored?
Cleanup
clause is implemented in this commit.
Now Given
covered beforeEach
, Cleanup
covered afterEach
. But still lack of support to before
and after
.
Some thoughts:
before
/ after
hook, it will be much simpler for respec-given
to implement this featurebefore
/ after
)need to clearly defined execution order
Then
clausebefore
s if is the first test in suitebeforeEach
sGiven
sWhen
sInvariant
sThen
And
sCleanup
safterEach
safter
s if is the last test in suiteit
blockbefore
s if is the first test in suitebeforeEach
sit
afterEach
safter
s if is the last test in suite
Given/When/Then doesn't cover the functionality that
after
covers.For example,