Testing

PropertyBasedDemoTest

Path
pkg14testing/src/test/java/pkg14testing/PropertyBasedDemoTest.java
Package
pkg14testing
Study order
0
Run
Read this file. It has no standalone main method.

There is no in-browser runner. This is the file from the curriculum, unchanged.

pkg14testing/src/test/java/pkg14testing/PropertyBasedDemoTest.java
1package pkg14testing;2 3import net.jqwik.api.*;4 5class PropertyBasedDemoTest {6 7    @Property8    void addIsCommutative(@ForAll int a, @ForAll int b) {9        Calculator calc = new Calculator();10        assert calc.add(a, b) == calc.add(b, a);11    }12 13    @Property14    void addWithZeroIsIdentity(@ForAll int a) {15        assert new Calculator().add(a, 0) == a;16    }17}