Exercise 7
info
This is an in-class exercise. An exercise page like this one will contain a brief description but is intended to be supplemented by discussion during our meeting time. Complete the exercise to the best of your ability in the time given. Feel free to talk with other students as you work, and do not be afraid to ask questions. Aim to complete as much as possible during our meeting, but you need not hand it in.
#
Learning ObjectivesObjectives
This exercise should help you practice with:
- Property-based Testing
- Jqwik
#
Task 1Consider the following two functions (which you have already seen in exercise 1):
- Write three properties for each of these functions.
- Both of these functions have fault(s). Does any of the properties you wrote in previous step helps with detecting any of the faults. If not, can you come up with a property that would do?
- Implement all the properties you came up with in Jqwik and run them against the above functions.
- Fix all the fualts so that all your property-based tests pass!
#
Task 2Using arbitraries and @Provide
annotation, write "provider" functions to generate:
- integer values 3, 5, 7, 13, 17, 23, 41
- odd integer values
- a guassian distribution of integer values between 0 and 100 with a mean of 50
- string values only comprised of digits of min length 3 and max length 10
- edge cases for doubles
- string values of variable length with character set of letters
a
throughz
with a0.5
probability of generating duplicate values