morning
Morning, anyone know of a good example of using property-based testing for validation?
Say I have a text field that's 1-50 alphanumeric chars, asserting the positive is simple enough - but what properties would you apply for failure cases?
Or do I just generate strings and have an if statement in the property?
morning
@glenjamin: good question. My current (limited) understanding of property based testing is exactly that. Have a property like ‘allows only valid inputs’ and throws strings from 0 - 5000 character strings at it. the property passes if the string was valid and the system allows access, or if an invalid string results in matching error message?
@glenjamin: have you done my property based testing?
i’ve used it a bit, mostly to try and do this type of testing
the problem is how best to know whether a string is valid or not, since that’s exactly what i’m testing
should the story / requirements not specify what should and shouldn’t be valid rather than the system under test?
yup, the bit i’m struggling with is how to express those in a property-based system
I’m insufficiently experienced to offer advice about it, having only read and played this weekend. I did have a v. useful conversation in #C08LK2DH7 about it, and received excellent advise. I would be keen to follow your endeavours, and assist where I can.
We all seem to be struggling with how to turn a spec into property based testing assertions.
My personal experiments around this 5-6 months ago led me to deduce it was much harder to write the code to generate and verify the test properties than the code to implement the solution. This was probably because it was too trivial a problem.
I ended up testing invariants like inverting the inputs and outputs with property based testing and the rest of the tests as normal example based.
My problem was a 'cheque parser' i.e. a number to words convertor that takes a number and expresses it in english words. e.g 120456 = "one hundred and twenty thousand, four hundred and fifty six"
I found property based testing unhelpful here and what few tests I wrote took me much longer than the implementation and were so complex I wanted tests around them to prove the property tests were correct!
We should start a virtual property based testing self help group 😉
part of my problem (i think), is that validation rules combine via intersection
but the inverse combines via union
so if my rules are 1-20 chars, alphanum. my inverse properties are <1, >20, non-alphanum
@glenjamin: hadn't thought of that but nice deduction. I think that's true of a lot of problems, if not all?
@maleghast: the company that I work for is hiring and they do offer H1B: https://news.ycombinator.com/item?id=11012931
@annapawlicka: what is it like working for W?
any good?
Yup. Good team and interesting problems to solve.
and how is life out there?
more laid back than in London :simple_smile:
:simple_smile:
must be all those hippies in SF 😉
haha very likely
but good to hear that you are enjoying yourself!!! and also great of you to drop in on lndclj!
I never left lndclj :simple_smile: the problem is the time difference. Everyone is asleep when I’m online
:simple_smile: