Markus Gaelli wrote:
Like, what if a test which doesn't have any assertion is simply not counted? Doesn't make sense to begin with, and then all the preconditions need to do is to bail out and the test doesn't count...
I don't understand this remark within that context.
I know a guy who is using that shouldnt: aBlock raise: anExceptionalEvent : [] idiom a lot ;-) , which is good for knowing what is really tested ;-) but otherwise does not provide any real assertion in the test. (See most of the BitBltClipBugs tests, which should be platform independent)
But that is a very valuable assertion! It means that we expect that code to run without an error where (by contradiction) it used to raise an exception. And not surprisingly, #shouldnt:raise: (and its other variants) is implemented as an assertion:
shouldnt: aBlock raise: anExceptionalEvent ^self assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent) not
Makes perfect sense and is a perfectly valid statement for a test. What I was referring to is a test like this:
MyTestCase>>testDummy "Really just a dummy, does nothing"
or like this:
MyTestCase>>windowsTestOnly "A test that only executes on windows" Smalltalk platformName = 'Win32' ifFalse:[^nil]. self assert: " ...something... ".
or any other form that does not exercise any assertion in the SUnit framework. It seems to me that such tests are really "empty tests", e.g., by having no assertions there isn't really a statement made whether this test succeeded or not (one might equally claim "it failed" - namely "to test anything"). In any case, I think a good solution would be to simply disregard any tests that don't assert anything.
Also, tests without any assertions still could execute lots of methods, which have nice post conditions with them. So besides being good smoke tests, they also could be seen as tests of that very methods.
If you mean to do this, you could just add a "self assert: true" at the end of it. At least that's a statement that the test is indeed doing something useful, like exercising code and asserting that it really does run through without any other exceptions.
Cheers, - Andreas