Skip to content

can I use this with AAA pattern? #3749

Answered by dubzzz
hkanthonyyip asked this question in Q&A
Discussion options

You must be logged in to vote

I'd say that yes AAA pattern can fit with fast-check and more generally with property based testing.

Most of the time when writing such tests, the "Arrange" phase will be the part defining what are the arbitraries being used by your property. But from time to time it can be larger than just them and contains some lines included within the predicate itself. For the "Act" and "Assert", I'd say they are still applying to the same things as for normal example based tests.

In other words for you test, I'd say:

test('should contain the same items', () => {
  fc.assert(
    fc.property(
      // Arrange
      fc.array(fc.integer()), (data) => {
        // Act
        const sorted = sort(data);

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dubzzz
Comment options

Answer selected by dubzzz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants