• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Programming Scala: testing tools

 
Marshal
Posts: 16631
278
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dean,

Looking at the book's table of contents, it seems there's very little discussion on testing tools. Which particular testing tool do you mention in the book? Are there any resources besides ScalaTest that you'd recommend?
 
Author
Posts: 23
8
Mac OS X Scala Monad
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't spend a lot of time on this topic. The language itself was a lot to cover! I briefly discuss the choices in the "tools" chapter.

I used MUnit (https://scalameta.org/munit/) because it's very lightweight. I've decided I dislike all the dialects the better known tools provide. Also, MUnit was available for early builds of Scala 3 ("Dotty") before ScalaTest supported it, so that helped when I started the 3rd Edition. MUnit also integrates with ScalaCheck, which is a requirement for me.

At work (Domino Data Lab), we use ScalaTest.
 
Junilu Lacar
Marshal
Posts: 16631
278
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. ScalaTest seems well suited for BBD-style tests. MUnit on the other hand is based on JUnit and has a different look and feel from ScalaTest. Besides being lightweight, is there anything else about MUnit that makes you prefer it over other testing tools?
 
Junilu Lacar
Marshal
Posts: 16631
278
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dean Wampler wrote:MUnit also integrates witch ScalaCheck, which is a requirement for me.


Can you tell us more about this? Why do you feel ScalaCheck is important?
 
Dean Wampler
Author
Posts: 23
8
Mac OS X Scala Monad
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I like the concept of BDD, but I strongly dislike the verbosity of BDD DSLs, along with the idiosyncrasies of their DSLs and the difficulty remembering them. Those DSLs are fine for the original intent of BDD, to communicate with stakeholders, but for tests that developers read and write, I prefer native idioms of the language with a helper library where needed. You already know the language and you can be concise.

ScalaCheck is used for property based testing, which I think is the strongest approach we have to correctness, besides what the types can enforce.

Suppose you write a type to encapsulate currency. Presumably it must obey accounting rules for addition and subtraction, multiplication by percentages (e.g., for computing taxes), have strict rules for rounding off to a desired number of decimal places, etc. These are properties. Tools like ScalaCheck (or the original framework in Haskell, called QuickCheck) make it easier to verify these properties.

Here are a resources that explain property-based testing:

https://increment.com/testing/in-praise-of-property-based-testing/
https://medium.com/criteo-engineering/introduction-to-property-based-testing-f5236229d237
reply
    Bookmark Topic Watch Topic
  • New Topic