Show error location when running integration tests with hedgehog
Clarification and motivation
Say we have the following integration test:
property $ integrationalTestProp $ do
addr <- originate contract contractName value balance
transfer tx1 addr
transfer tx2 addr
transfer tx3 addr
┏━━ src/Michelson/Test/Integrational.hs ━━━
237 ┃ integrationalTestProp :: MonadTest m => IntegrationalScenario -> m ()
238 ┃ integrationalTestProp scenario =
239 ┃ integrationalTest (maybe succeededTest (failedTest . pretty)) scenario
┃ │ <Error message goes here>
┃ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
First, we don't want the implementation of integrationalTestProp
to show up in the logs. We should add the HasCallStack
constraint and withFrozenCallStack
to integrationalTestProp
to prevent this.
Even after addressing this, it still won't be clear which of the 3 transfer operations caused the error.
In order to improve this, maybe we could integrate our integration testing engine better with hedgehog, and have hedgehog point to the exact integration test step that caused the failure.
My first thought was to save the callstack inside ScenarioError
when a step fails. And then, in integrationalTestProp
, we use the callstack to transform our ScenarioError
into a Hedgehog.Internal.Property.Failure
. Maybe there are some internal hedgehog functions we could use to aid us here.
Some investigation and experimenting might be required.
Acceptance criteria
If I purposefully break an integration test that uses integrationalTestProp
, hedgehog's logs will show me the exact step that triggered the error.