Podcast

150: Functional Programming Property Based Testing with Eric Normand

By Test Guild
  • Share:
Join the Guild for FREE
Eric Normand TestTalks Feature


In this episode we’ll be Test Talking about Functional Programming and Property-Based Testing. As a tester, I feel it’s important to understand the latest trends and techniques in software development. Especially if it’s a developer-based testing technique that we can educate our programmers about to help create better quality software.

Eric Normand is the founder of PurelyFunctional.tv, where he develops Clojure training materials as well as on-site and in-person training in Clojure-related technologies. He also consults on software architecture, development practices, DevOps, and functional programming.

About Eric Normand

Eric Normand Headshot

Eric Normand is a long time functional programmer excited to see it entering the mainstream. He loves teaching and cooking. You can learn Functional Programming from him at PurelyFunctional.tv and read his thoughts in The PurelyFunctional.tv Newsletter. If you visit him in New Orleans, you can meet his wife and daughter. He'll even make you some gumbo if you tell him you're coming.

Quotes & Insights from this Test Talk

  • Functional programming is kind of trending right now, but it's a paradigm of programming that focuses on functions as the main way to make abstractions. So you see a lot of use of functions and higher order functions that is functions that take other functions as arguments or return function. And you'll also see functional programming or functional programming languages with immutable data structures. There's been a lot of research into type systems in functional programming so it's basically a paradigm where you're dealing with immutable values and transforming them using functions.
  • Functional code is very easy to test as you can imagine because it's all acting in memory. It's the inputs you know give it some inputs and you check the output if it's working it's working.
  • Property based testing is a kind of random testing and basically it means you generate random data and instead of saying because it's random inputs to your function or whatever you're calling you don't know what the result is supposed to be but you might know like a property of it like a mathematical property like you might say well it always should be greater than zero. I don't know what the number is going to be but I know it's not you know it's a positive number. So if you could come up with these properties you can actually express a whole class of tests. So instead of just saying one or two examples you can have the computer generate hundreds or thousands of random tests that just randomly finding some finding bugs in your in your code.
  • One of the one of the great things about clojure is that it does run on the JVM and it has really seamless interop. So you can just call methods on you know any object you have a handle to just very easily.
  • So what the system does is it will remove a character at random but systematically So it's going to try to remove all of them eventually and it'll also decrease the Unicode character. You know the Unicode code. So it's trying to shrink that string down into the smallest string that still breaks your test that still fails your test and it does all of that automatically. So you know you could have 10000 characters in there and then it could shrink it down to the one character that's breaking it. So that really helps you debug your system because you're like oh this one character string is breaking my you know my database query. The cool thing is that shrunken version can become an example in your test suite so that you can avoid a regression on that same thing again.
  • One piece of actionable advice I would say, find a property based testing library and your language and convert some of your example based tests to use random data instead of the examples that you've hardcoded in in your test.

Resources

Connect with Eric Normand

May I Ask You For a Favor?

Thanks again for listening to the show. If it has helped you in any way, shape or form, please share it using the social media buttons you see on the page.

Additionally, reviews for the podcast on iTunes are extremely helpful and greatly appreciated! They do matter in the rankings of the show and I read each and every one of them.

SponsoredBySauceLabs

Test Talks is sponsored by the fantastic folks at Sauce Labs. Try it for free today!

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

267: Smart Test Execution with Eran Sher

Posted on 08/25/2019

Do you run an entire automation test for every build because you don’t ...

266: Automation Journey and TestNG with Rex Jones II

Posted on 08/18/2019

In this episode we’ll test talk with Rex Jones about his automation testing ...

265: TestProject a Community Testing Platform with Mark Kardashov

Posted on 08/11/2019

In this episode, we’ll talk to Mark Kardashov, CEO and Co-Founder of TestProject, ...