The Artima Developer Community
Sponsored Link

Indeterminate Heuristics
First Impression: Scala Goodies
by Dale Asberry
January 23, 2012
Summary
I'm test-infected and that's why one of my first exciting Scala discoveries was ScalaTest

Advertisement

Actually, the first big thing I noticed about Scala was the crispness I could write my code. Put it together with the ScalaTest framework and you get the following highly-readable and obvious test snippet (excerpted from ScalaTest Testing with Mock Objects: Using Borachio):

val mockCollaborator = mock[Collaborator]

mockCollaborator expects 'documentAdded withArgs ("Document")
mockCollaborator expects 'documentChanged withArgs ("Document") repeated 3 times

classUnderTest.addDocument("Document", new Array[Byte](0))
classUnderTest.addDocument("Document", new Array[Byte](0))
classUnderTest.addDocument("Document", new Array[Byte](0))
classUnderTest.addDocument("Document", new Array[Byte](0))

Clean.

Talk Back!

Have an opinion? Readers have already posted 4 comments about this weblog entry. Why not add yours?

RSS Feed

If you'd like to be notified whenever Dale Asberry adds a new entry to his weblog, subscribe to his RSS feed.

About the Blogger

R. Dale Asberry been hacking since 1978, professionally since 1990. He's certified in Java 1.1 and has a four digit MCP number. He discovered Jini at the 2000 JavaOne and has been building incredibly cool, dynamic, distributed architectures ever since! Over time, he's discovered several principles that have contributed to his success - they are the Princples of: Enabling Others, Simplicity, No Complaining, Least Work, Least Surprise, Least Damage, and "It Just Works".

This weblog entry is Copyright © 2012 Dale Asberry. All rights reserved.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use