Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fc.assert pass with path in the config #251

Closed
maciejmyslinski opened this issue Dec 2, 2018 · 4 comments
Closed

fc.assert pass with path in the config #251

maciejmyslinski opened this issue Dec 2, 2018 · 4 comments

Comments

@maciejmyslinski
Copy link

maciejmyslinski commented Dec 2, 2018

Hey!
My property-based test fails (it takes about 800ms, this is ok ✅)
When I copy seed and provide it to fc.assert, it fails (again, it's ok ✅)
When I copy both seed and path and provide it to fc.assert, test passes (it takes about 2ms, it's bad 😢 ❌)

I looks like this:

fc.assert(
  fc.asyncProperty(
    fc.commands(commands),
    async cmds => {
      const getInitialState = () => ({ model, real })
      await fc.asyncModelRun(getInitialState, cmds)
    }
  ),
  {
    seed: 1842107356,
    // path: '31:10' <–– when this is uncommented, the issue occurs.
  }
)
@dubzzz
Copy link
Owner

dubzzz commented Dec 2, 2018

It is unfortunately a known issue, fc.commands cannot be replayed for the moment.

In the documentation: https://github.com/dubzzz/fast-check/blob/master/documentation/Arbitraries.md
WARNING: fc.commands cannot be replayed for the moment

To be able to shrink those, the path would have to contain lots of additional details :/

@dubzzz
Copy link
Owner

dubzzz commented Dec 12, 2018

Here is what happens when you shrink fc.commands:

Let's consider the selected commands are [c0, c1, c2, c3, c4, c5, c6] .
During the execution c2 was not executed because it does not fulfill its preconditions and commands c5 and c6 neither because c4 found a bug.

If we were using fc.array to generate our commands - it was the case initially - we would not have been able to take into account that some commands are not relevant because not ran.

fc.commands in the contrary takes that into account, instead of shrinking [c0, c1, c2, c3, c4, c5, c6] , it shrinks [c0, c1, c3, c4] . In addition it knows that c4 raised a red flag, so it should always keep it in the shrinking process.

The path as defined today, cannot give fc.commands enough details to be able to know which commands were executed, failed.. That is the main reason why it is not working properly.

For the moment, I have no nice way to make it work, except relying on fc.array if you really care about having a working path. I would say that today it is a won't fix but I keep the point in mind as it is also something I would be interested in.

@dubzzz
Copy link
Owner

dubzzz commented Jan 25, 2019

I should come with some kind of workaround solution in the next minor version of fast-check. I have an idea that should work fine for this purpose.

Stay tuned :)

dubzzz added a commit that referenced this issue Jan 27, 2019
Replaying previously executed runs is a must have feature for property based testing frameworks.
Because of the specificities of commands, commands were not eligible to replay.

This commit adds the replay capabilities to commands by specifying an extra parameter when defining them (replayPath).
Please note that commands arbitraries should not be shared accross multiple runs.

Related to #251
dubzzz added a commit that referenced this issue Jan 29, 2019
Replaying previously executed runs is a must have feature for property based testing frameworks.
Because of the specificities of commands, commands were not eligible to replay.

This commit adds the replay capabilities to commands by specifying an extra parameter when defining them (replayPath).
Please note that commands arbitraries should not be shared accross multiple runs.

Related to #251
dubzzz added a commit that referenced this issue Feb 4, 2019
Replaying previously executed runs is a must have feature for property based testing frameworks.
Because of the specificities of commands, commands were not eligible to replay.

This commit adds the replay capabilities to commands by specifying an extra parameter when defining them (replayPath).
Please note that commands arbitraries should not be shared accross multiple runs.

Related to #251
@dubzzz
Copy link
Owner

dubzzz commented Feb 4, 2019

PR #294 should solve the issue. Feel free to re-open if it does not.

(not released yet - I will let you know as soon as it gets released)

@dubzzz dubzzz closed this as completed Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants