A test that asserts nothing has only asserted that the code ran through
without throwing an error. :-)

I like your proposal that such a test is an inherently failing test.


(Of course, that will result in the student adding a single assertion at
the end, of the form "self assert: true"!)

On Tue, Nov 21, 2017 at 4:07 PM, Prof. Andrew P. Black <bl...@cs.pdx.edu>
wrote:

> While we are discussing colors, what should we do about a test that does
> not make any assertions at all?
>
> A couple of years ago, a smart student who was working on a testing
> dialect for me decided that such tests should be in a new category all of
> their own.  Later I simplified things and just made these tests fail.  I am
> pretty convinced now that this is the right behaviour.  It certainly suits
> my purposes (teaching TDD); if the student omits to make any assertions,
> they have a failing test.  The message is: "Failure: test made no
> assertions".
>
> Currently, such a test is green in Pharo.  In 2013, I filed a bug report
> on a bunch of tests of #printOn: on collections that made no assertions.
> (The test writer didn’t understand how streams worked, and made assertions
> for each element of the empty string.)  I was reminded of this just this
> week, because those tests have yet to be fixed.  I suspect that if they had
> been yellow, rather than green, then they would have been fixed before now.
>
> I plan to fix those tests on Friday, but I also wonder about changing the
> behaviour of the testing framework.  What do you think?
>
>         Andrew
>
>
>

Reply via email to