Lawrence_elixir

Lawrence_elixir

13) ElixirConf EU 2019 - Introduction to stateful property based testing - Tomasz Kowal

@tomekowal - Software Developer at ClubCollect

Introduction to stateful property based testing

Talk in three words: Stateful Property-Based Testing

Abstract
Property-based testing is a technique for writing tests that use a framework for creating test inputs and user-defined properties for validating outputs. Generating data allows for finding bugs that would be impossible to catch by regular unit tests: e.g. too big to encode by hand. This talk will explain why it is worth getting into PBT by introducing successful usages of PBT for testing AUTOSAR, LevelDB and Dropbox. All these examples use stateful testing, so the second half of the talk describes steps to create a stateful test for a simple key-value store.

Objectives
Introductory materials for PBT often focus on straightforward cases which are great for teaching but fail to show the true potential of PBT. The goal of this talk is a high-level overview that is both encouraging for beginners but also maps the road to mastering Property-Based Testing.

Audience
Developers who have heard about Property-Based Testing but are not convinced yet about its usefulness.

The speaker
Tomasz has worked with functional languages for over eight years and loves learning and teaching about concepts and techniques.

All will be added to the ElixirConf EU 2019 Talks List or via the #elixirConfEU2019 tag.

Most Liked

keathley

keathley

If you’re testing with timers then you’ll want to add the timers to the model itself. After all time is part of your state at that point. You can treat timer calls as a command to generate. This allows you to deterministically control your tests and consequently run them much faster. It also allows you to induce weird failures that you wouldn’t normally see (like firing timers in incorrect orders for instance). I typically do this by shimming the timer module. My SUT uses the shim. In production it’ll use the real timer module. In my tests they’re just dummy calls.

tomekowal

tomekowal

Is that a standard cache?
I am not sure I would use PBT for such case. It makes sense where there is an explosion of different states. In case of cache, there are two: the data is there, or it isn’t.
Other argument for not testing it this way is that usually after deleting the session, you fetch it from the DB or somewhere else. It doesn’t affect how your system behaves to the outside world. It is an implementation detail that can you should leave out of model.
If there is other stuff depending on it, and you want to test it with PBT, you can pass current time to the functions as an argument. That makes it easier to test in general - not only for PBT :slight_smile:

jmitchell

jmitchell

That’s not what I had in mind, but those are good points.

Oh that makes sense–thanks.

The example requirement was intended as an explicit feature of the server API. Although clients can’t be sure data isn’t retained longer without being able to audit the running code, they can at least know the server behave as if they have a clean slate after waiting >70s. The PBT would help in case this guarantee ever needed to be audited and help maintain the guarantee as the implementation evolves.

Another potential reason for the requirement is avoiding per connection session data becoming a memory leak.

Where Next?

Popular in Talks Top

axelson
ElixirConf 2017 - Elixir by the Bellyful - @bryanhunter Elixir makes me happy! Since 2007 I have been on the...
New
axelson
by @girlsleuth Whether you call it UI testing, End-to-End Testing, End-to-User Testing, or Acceptance Testing–it is often an intensely ...
New
axelson
ElixirConf 2017 - The Power of Zero - Andrew Forward Automation is hard, but the benefits can be phenomenal....
New
axelson
by @takasehideki Can you imagine that your Elixir code will be executed as a hardware circuit on an FPGA? The FPGA (Field-Programmable...
New
axelson
ElixirConf 2017 - Implementing a MQTT client in Elixir - @gausby Elixir has excellent support for binary pat...
New
New
New
Lawrence_elixir
@keathley - Senior Engineer Bleacher Report and Elixir Outlaws presenter Talk: Building Resilient Systems with Stacking Talk in three w...
New
axelson
ElixirConf 2017 - Elixir Power Tracing - Gabi Zuniga Tracing is a technique for tracking events during a pro...
New
axelson
by @jola Can you write a performant string processing scripts in Elixir? This talk attempts to answer that question while incrementally...
New

Other popular topics Top

freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New

We're in Beta

About us Mission Statement