Events are being added to SpecSuite with the goal of providing more feedback during tests, adding an AfterEach approach for teardown (Fixes #9), and providing a foundation for extensibility (WBProxy and Scenario can be built much more cleanly on top of events).
The following events are fired by SpecSuite:
BeforeEach: Called before each spec in suite (setup)
Result(Spec): Called when spec has result
AfterEach: Called after each spec in suite (teardown)
Note: BeforeAll and AfterAll type events are best handled in the listener Initialize and Terminate.
Before
Public Function Specs() As SpecSuite
Set Specs = New SpecSuite
Specs.BeforeEach "BeforeEach"
' no Result or AfterEach
With Specs.It("...")
End With
' InlineRunner only reports results after suite has run
' (also, RunSuite is a misnomer since suite has already run at this point)
InlineRunner.RunSuite Specs
End Sub
Public Sub BeforeEach()
' Run public module sub before each spec
End Sub
After
' ResultFixture.cls
'
Private WithEvents pSpecs as SpecSuite
Public Function ListenTo(Specs As SpecSuite)
Set pSpecs = Specs
End Function
Private Sub pSpecs_BeforeEach()
' Setup fixture
End Sub
Private Sub pSpecs_AfterEach()
' Teardown fixture
End Sub
Private Sub pSpecs_Result()
' (used by reporters to show results as they happen)
End Sub
' Specs.bas
'
Public Function Specs() As SpecSuite
Set Specs = New SpecSuite
Set Reporter = New ImmediateReporter
Set Fixture = New ResultFixture
Reporter.ListenTo Specs
Fixture.ListenTo Specs
' -> BeforeEach, Result, and AfterEach are called for each spec
With Specs.It("...")
' -> BeforeEach
' .Expect...
End With
' -> Result, AfterEach
End Function
Tasks
[x] Remove old, undocumented/unmaintained code (WBProxy and Scenario). May add back later, especially since WBProxy will work much better with events
[x] Switch from callbacks to events and add "after-each" event (no good way to do this before)
[x] Switch InlineRunner and DisplayRunner to reporters (use events)
Evented approach
Events are being added to
SpecSuite
with the goal of providing more feedback during tests, adding anAfterEach
approach for teardown (Fixes #9), and providing a foundation for extensibility (WBProxy and Scenario can be built much more cleanly on top of events).The following events are fired by
SpecSuite
:BeforeEach
: Called before each spec in suite (setup)Result(Spec)
: Called when spec has resultAfterEach
: Called after each spec in suite (teardown)Note:
BeforeAll
andAfterAll
type events are best handled in the listenerInitialize
andTerminate
.Before
After
Tasks
WBProxy
andScenario
). May add back later, especially sinceWBProxy
will work much better with eventsInlineRunner
andDisplayRunner
to reporters (use events)Closes #7