failing test in writing files
Hi there, I have a failing test and was wondering if anyone would have a sense as to why: | testString filename file | testString := 'ascii String'. filename := 'test-file-' , 99 atRandom printString , '.txt'. filename asFileReference ensureDelete. file := filename asFileReference writeStreamDo: [ :stream | stream nextPutAll: testString; crlf ]. self assert: file species = FileStream. Many thanks, Sheri
self assert: (file species isKindOf: FileStream) But that is a weird test. What is the point ? You have to test behaviour, like write a file and see if it was written. Testing types is very seldom done, because this is an implementation detail.
On 04 Dec 2014, at 01:32, sheridan@sheridan-mahoney.com wrote:
Hi there,
I have a failing test and was wondering if anyone would have a sense as to why:
| testString filename file | testString := 'ascii String'. filename := 'test-file-' , 99 atRandom printString , '.txt'. filename asFileReference ensureDelete. file := filename asFileReference writeStreamDo: [ :stream | stream nextPutAll: testString; crlf ]. self assert: file species = FileStream.
Many thanks,
Sheri
Sven Van Caekenberghe wrote:
self assert: (file species isKindOf: FileStream)
But that is a weird test. What is the point ?
You have to test behaviour, like write a file and see if it was written. Testing types is very seldom done, because this is an implementation detail.
Thanks Sheri and Sven. I learnt a new aspect of design philosophy today. Thats one thing I like about contributing to open source - the opportunity for learning, especially from the questions that other people ask. cheers -ben
On 04 Dec 2014, at 01:32, sheridan@sheridan-mahoney.com wrote:
Hi there,
I have a failing test and was wondering if anyone would have a sense as to why:
| testString filename file | testString := 'ascii String'. filename := 'test-file-' , 99 atRandom printString , '.txt'. filename asFileReference ensureDelete. file := filename asFileReference writeStreamDo: [ :stream | stream nextPutAll: testString; crlf ]. self assert: file species = FileStream.
Many thanks,
Sheri
Step into #writeStreamDo: ...
participants (3)
-
Ben Coman -
sheridan@sheridan-mahoney.com -
Sven Van Caekenberghe