Property testing

During ElixirConfEu in Barcelona, I learned about Property Testing. It looks pretty neat and it got me interested. Basics sound quite easy but there’s more than meets the eye and I’ve been reading/listening about it for a while.
As I don’t feel comfortable enough to do a deep dive into the topic I will do an introduction to it. After I get a deeper understanding with some “real life” examples (or maybe doing them myself) I will write a follow-up.

Property testing is a term originating from Haskell lib called QuickCheck. It was created to ease the pain of writing many tests. Instead of writing n specific unit test you can generate them.

Using QuickCheck (here is the list of ports to your language of choice) you define a property of a piece of code you’re testing.

For trivial example – if you were to write your own ordering function you can define few properties – if you order it twice the result won’t change, the only change is the position of elements (so you don’t hanger values) and so on.

QuickCheck then generates data, runs n tests using this random data and if it finds failing case it executes something called shrinking – trying to find minimal failing case. It can ease up debugging or seeing straight away what’s wrong.

While it’s all fun, I’m still not sure what are the cases in a commercial code where this is the best approach. Also, turns out that properties also form kind of patterns – and I’m yet to learn about all this.

Nevertheless, I’m quite hyped and want to learn more – it seems more of easy to get, hard to master useful tool than a novelty, but only time will tell.

OpenSettlersII #6

As always, a commit!

Slowly crawling towards functioning lib.

This commit is not really that different from other, yet I started using Elixir convetion for return values: the tuple {:ok, response}/{:error, message}. I am quite not happy with  the as_server function and I guess I will rename/rewrite it later. It’s quite obvious what it does – checks the rightmost bit and responds and sets “as server” to according boolean value.

Also, encoding and decoding version – I have no way of validating it, but I’m not sure if I should. This is one of two things I need to check before proceeding – another one being the Signature – I’m not sure if it’s version specific or not, so that’s something to get to know before coding it.

And that’s it for now 🙂

Elixir Conf Eu

Hello!

There was a week without updates as I went to the Barcelona to attent Elixir Conf Eu – and afterwards made a short vacation. This time I won’t be as specific as I was with ErlangFactoryLite; it was way bigger conference and I didn’t get to see all talks as well. Truth be told – but it’s a problem with any bigger conference – overall level of talks was lower than EFL’s ones – but it’s inevitable. Organisation was really good, as the venue.

I have some stuff to share, less now, more later when I deep dive into them.

First, there’s something called QuickCheck. It’s enables to do Property Testing – I’m not feeling comfortable enough with my knowledge of this subject to try explaning it, but I’m looking forward getting to know it more and write about it here!

Another thing is PureScript (looks like you can read a recommended book here for free!). It’s compiled to JavaScript (as all of those new front-end stuff), but apparently you can also compile to Erlang and some other as well! It’s influenced by Haskell, more elastic and powerful than Elm (which is easy to learn, but apparently if your app doesn’t fit Elm’s architecture you will have a lot of pain). I never did anything serious in frontend from start to finish (I did some work with React + Cerebral, but I wouldn’t call myself front-end specialist) so I guess this could be an interesting start.

Nerves strikes again, as this time distributed computing on Rasps was shown. It’s nice to see that this project grows. And also: nice project to get started: make temperature controller for beer fermentation (old fridge, old lightbulb for hear and rasp pi running nerves)!