Testing akka actor termination

When testing akka code, I want to make sure a particular actor gets shut down within a time limit. I used to do it like this:  Thread.sleep(2.seconds) assertTrue(actorRef.isTerminated()) That isTerminated method is deprecated since Akka 2.2, and good thing too, since my test was wasting everyone’s time. Today I’m doing this instead: import akka.testkit.TestProbeval probe = …

Read moreTesting akka actor termination

A suggestion for testing style in Clojure

Getting a test to fail is one thing; getting it to express why it failed is another.Clojure.test provides an assertion macro: is (deftest “my-function”   (testing “some requirement”    (is (something-that-evaluates-to-bool (arg1) (arg2))     “Message to print when it’s false”))) When this assertion fails, in addition to the message, “expected” and “actual” results print. The is macro tries to …

Read moreA suggestion for testing style in Clojure

Property-based testing of higher-order functions

Property-based testing and functional programming are friends, because they’re both motivated by Reasoning About Code. Functional programming is about keeping your functions data-in, data-out so that you can reason about them. Property-based testing is about expressing the conclusions of that reasoning as properties, then showing that they’re (probably) true by testing them with hundreds of …

Read moreProperty-based testing of higher-order functions