Hi everyone!
Lately I've been playing with/digging into the announcements model for
SUnit, and have a couple of questions about it.
I'm trying to understand the model and I am by no means an expert to it. Any
pointers/references/feedback is appreciated.
1) As expected TestCaseEnded is notified after a test case is run in
TestResult>>#runCase:, but after some tests I've noticed that the
announcement (which is created with the TestResult instance as collaborator)
is sent before the passing test case is added to the TestResult instance.
That means that one gets notified that a test case has been run
successfully, but when inspecting the result, that test case won't be there:
runCase: aTestCase
[
aTestCase announce: TestCaseStarted withResult: self.
aTestCase runCase.
*aTestCase announce: TestCaseEnded withResult: self.
self addPass: aTestCase*]
on: self class failure , self class skip, self class warning,
self class
error
do: [:ex | ex sunitAnnounce: aTestCase toResult: self]
Is this the expected behavior?
2) When a test case does not pass (for whatever reason), the failure is
handled and the TestResult instance is updated, but a TestCaseEnded
announcement is not sent. So there's a chance that you'd get a
TestCaseStarted announcement, but never receive a TestCaseEnded announcement
if it didn't pass:
runCase: aTestCase
[
*aTestCase announce: TestCaseStarted withResult: self.*
aTestCase runCase.
aTestCase announce: TestCaseEnded withResult: self.
self addPass: aTestCase]
on: self class failure , self class skip, self class warning,
self class
error
do: [:ex | *ex sunitAnnounce: aTestCase toResult: self*]
Is this the expected behavior?
3) When a TestSuiteEnded is announced (TestResult>>#updateResultsInHistory),
the announcement instance is created passing in the TestCase subclass as
result. So, when sending #testResult to the annoucement, one does not get a
TestResult instance (as expected) but the TestCase subclass.
updateResultsInHistory
|classesToNotify|
classesToNotify:= Set new.
#(#passed #failures #errors) do: [ :status |
(self perform: status) do: [ :testCase |
classesToNotify add:testCase class.
self class updateTestHistoryFor: testCase status:
status ] ].
*classesToNotify do:[:cl | *
cl historyAnnouncer announce: (*TestSuiteEnded result: cl*)]
4) I've read an old post about using a Dictionary instead of storing the
TestResult instance as history, and it seemed like that was the intended
design. The only issue I see there is that there could be potentially
duplicated code in writing the interpretation of that dictionary (ie.
#passed, #failures, #defects, etc..). Has anyone worked with TestCase
results history before? if So, which was your approach to do it?
Cheers,
Nico PM
--
View this message in context:
http://forum.world.st/About-the-announcements-model-for-SUnit-tp4863569.html
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.