question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

skipAllAfterTimeLimit throws an error instead of skipping tests

See original GitHub issue

🐛 Bug Report

skipAllAfterTimeLimit throws an error instead of skipping the remaining tests like the name suggests

To Reproduce

Steps to reproduce:

    it(‘should skip tests’, async () => {
        jest.useRealTimers();
        const property = fc.asyncProperty(
            fc.constant(''),
            async () => {
                await new Promise(resolve => setTimeout(resolve, 100));
                expect(true).toBe(true);
            }
        );
        await fc.assert(property, {
            numRuns: 10,
            skipAllAfterTimeLimit: 1,

        });
    });
});

Expected behavior

It should skip all remaining tests instead of throwing error. We could have a parameter, similar to maxSkipsPerRun, to specify the max amount of tests it can skip.

Your environment

Packages / Softwares Version(s)
fast-check 1.16.2
node 10.14.1
TypeScript 3.4.5

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ZeRegocommented, Oct 23, 2019

I see that the fail message with very verbose mode only shows the generated value. Could we add the seed and path to each one ?

Current error message:

Error: Failed to run property, too many pre-condition failures encountered

Ran 9 time(s)
Skipped 1001 time(s)

Execution summary:
√ [""]
√ [""]
√ [""]
√ [""]
√ [""]
√ [""]
√ [""]
√ [""]
√ [""]
! [""]
! [""]
...
! [""]

Hint (1): Try to reduce the number of rejected values by combining map, flatMap and built-in arbitraries
Hint (2): Increase failure tolerance by setting maxSkipsPerRun to an higher value
1reaction
dubzzzcommented, Oct 11, 2019

skipAllAfterTimeLimit

I agree that skipAllAfterTimeLimit was not well defined. The initial idea behind this feature was: mark runs as skipped as soon as the time limit expired.

In fast-check, a run can have 3 different states: success, failure, skipped (mainly triggered by fc.pre). Initially skipAllAfterTimeLimit was supposed to mark all runs as skipped after the time limit.

There are two possible outcomes:

  • timeout occurs during shrinking: shrinking will be interrupted by marking all the shrunk values as skipped
  • timeout occurs while there are remaining values to generate: test will fail because it will never be able to reach the required number of tests

See https://github.com/dubzzz/fast-check/pull/425 which just fix the feature as it was initially defined.

interruptAfterTimeLimit

On the contrary, interruptAfterTimeLimit does not mark runs as skipped. It just stops the execution of the test suite. There two possibilities: either it should be marked as a failure, or a success with not enough runs (see markInterruptAsFailure in https://github.com/dubzzz/fast-check/pull/428).

Internally interruptAfterTimeLimit really interrupts the execution either by marking it as failure or as success. While skipAllAfterTimeLimit just marks everything as skipped.

conclusion

  • skipAllAfterTimeLimit: mark runs as skipped after timeout (shrunk values will still be produced)
  • interruptAfterTimeLimit: stop execution after timeout - test is considered as success if it has never encountered an issue - I have to double check in my implementation that if it happens while shrinking the reported error is the smallest failure not the shrunk where it stopped
  • interruptAfterTimeLimit and markInterruptAsFailure:true: stop execution after timeout - an interrupted test is considered as a failed test - maybe the contrary markInterruptAsSuccess

Actually I’m still looking for the right way to add this interrupt/skip/whatever feature (maybe replacing skipAllAfterTimeLimit).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Methods for Skipping Tests | Apple Developer Documentation
Skip tests when meeting specified conditions. ... Throw an XCTSkip error when you have other circumstances that result in skipped tests. For example:....
Read more >
Cannot determine how Jest is skipping tests #4763 - GitHub
When I run Jest in watch mode and hit "a" (to run all tests), Jest still skips ... skipped 1 test instead of...
Read more >
swift - iOS Testing: Is there a way to skip tests? - Stack Overflow
To skip a test, call one of the new XCTSkip* functions from within a test method or setUp(). For example: func test_canAuthenticate() throws...
Read more >
Maven Surefire Plugin – Skipping Tests
To skip running the tests for a particular project, ... You can also skip the tests via the command line by executing the...
Read more >
Parameters | fast-check | Property based testing framework
Documentation for API Reference | fast-check | Property based testing framework. ... Should the thrown Error include a cause leading to the original...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found