How does functionaljava testing compares to QuickCheck?

228 views
Skip to first unread message

Tomasz Kalkosiński

unread,
Aug 23, 2015, 1:55:53 AM8/23/15
to Functional Java
Hi

I've found reactivejava testing library to be based on QuickCheck. However, there is sparse documentation about it. In terms of this question: http://stackoverflow.com/a/23267203, which parts of QuickCheck is supported by functionaljava's testing library?

My second question is about PropertyTestRunner. Is it functional? Can you show me a few examples how does it work? I counldn't find any example on my own.

Regards,
Tomasz Kalkosiński

Mark Perry

unread,
Aug 23, 2015, 10:06:42 AM8/23/15
to Functional Java
Hi Tomasz,


I believe that Tony Morris implemented the FunctionalJava version of QuickCheck based closely on the original paper (http://www.eecs.northwestern.edu/~robby/courses/395-495-2009-fall/quick.pdf). You can see that from the use of Property, Arbitrary, Gen, Coarbitrary, Random and Result.  Suprisingly, the orignal implementation fits on a single page in the appendix.

You asked about the question on stackoverflow, I assume you mean how it addresses the current top answer that states the author's key Haskell QuickCheck features of:
1 - generates random test data
2 - shrinks data
3 - simple data to more complex

FunctionalJava's quickcheck supports 1, 2 and I believe supports 3.  For 3, I see this in practice, but haven't taken the time to know how this works.

Regarding the PropertyTestRunner, I assume you mean by functional is it implemented and working?  Yes it is, we use it to test various classes and it adds the properties tested to the usual JUnit test report.  We had previously used ScalaCheck for testing the project, but we are gradually moving more of the properties over to the FJ Quickcheck.  For an example, try the ListProperties class in the props-core component.

Regards,
Mark

Tomasz Kalkosiński

unread,
Aug 24, 2015, 2:26:27 AM8/24/15
to Functional Java
Hi Mark,

Thank you for your answer. I've checked ListProperties with PropertyTestRunner and it works great. There are other files I've found e.g. IntegerOverflow that can be moved to use PropertyTestRunner as well.

As I'm inspired by a talk by John Hughes - Testing the Hard Stuff and Staying Sane (https://www.youtube.com/watch?v=zi0rHwfiX1Q) - is there a module for FJ that laverages state machine testing? Or is it in works? As I understand it, it can be doable using current FJ-QC architecture, e.g. Generator, Arbitrary and Shrink, but some other classes are in need too: State, Command, maybe others.

Regards,
Tomasz

Mark Perry

unread,
Aug 25, 2015, 11:43:01 AM8/25/15
to Functional Java

There are many files that need to be changed to use the PropertyTestRunner.  Would you like to make this particular change and create a pull request?

There are no current plans for state machine testing, however you should be able to do it with what is already there.  I would generate arbitrary functions and then map over that to produce arbitrary states (using the existing State class).  What are you referring to with your mention of Command?

I haven't watched that talk yet, I assume there are some hints in it on implementing state machine tests.

Mark

Tomasz Kalkosiński

unread,
Aug 27, 2015, 4:26:25 PM8/27/15
to Functional Java
I won't submit pull request for now. I was just playing with how it works and how can it be used with FSM testing.

FSM testing with QuickCheck is a commercial extension used by John Hughes. His talk describes it briefly. I would definietly start with existing classes. I understand Command as a tuple: precondition, actal state change and postcondition. Arbitrary function would generate such Commands to be executed one by one and verify during a process.

Actually I've found a very interesting blog post by Guillermo Winkler here: http://blog.guillermowinkler.com/blog/2015/04/12/verifying-state-machine-behavior-using-test-dot-check/. He's doing the same thing in Clojure. What's even more interesting he has been inspired by the same talk I've mentioned!

I've proposed FSM testing with QuickCheck as a topic for our internal Hackaton. We'll see how it works. We're not yet familiar with FJ so we might develop it very slowly.

Regards,
Tomasz

Matteo Moci

unread,
Apr 7, 2017, 12:41:54 PM4/7/17
to functio...@googlegroups.com
Hi All, 
I am just learning property checking and very interested in testing a FSM with property checking. 
I'd like to test a simple toy FSM, something like a ticket dispenser like John Hughes mentioned in his talks. 

I read this sentence: 

"I would generate arbitrary functions and then map over that to produce arbitrary states (using the existing State class)"

and thought if there there some basic examples for doing it in functionaljava? 

I also saw scalacheck's approach using Commands (mentioned here https://www.scalacheck.org/files/scaladays2014/index.html#1 and cited previously by Tomasz) as an alternative way of doing it, but didn't find anything similar in functionaljava yet. 

Thanks! 
Matteo



--
You received this message because you are subscribed to the Google Groups "Functional Java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to functionaljava+unsubscribe@googlegroups.com.
To post to this group, send email to functionaljava@googlegroups.com.
Visit this group at http://groups.google.com/group/functionaljava.
For more options, visit https://groups.google.com/d/optout.



--
Matteo Moci
http://mox.fm

Matteo Moci

unread,
Apr 28, 2017, 9:02:31 AM4/28/17
to functio...@googlegroups.com
anyone? no quickcheck-style examples in functionaljava?

To post to this group, send email to functio...@googlegroups.com.
--
Matteo Moci
http://mox.fm

Roy Brokvam

unread,
Apr 28, 2017, 9:24:07 AM4/28/17
to functio...@googlegroups.com
Hi, Matteo!

You will find that the State class has property tests in props-core/src/test/java/fj/data/StateProperties.java. Is that what you're looking for?

Regards,

To post to this group, send email to functionaljava@googlegroups.com.

Matteo Moci

unread,
Apr 28, 2017, 12:33:23 PM4/28/17
to functio...@googlegroups.com
Thanks Roy! I'll start from there! 

--
You received this message because you are subscribed to the Google Groups "Functional Java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to functionaljava+unsubscribe@googlegroups.com.
To post to this group, send email to functionaljava@googlegroups.com.
Visit this group at https://groups.google.com/group/functionaljava.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages