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

Expose the FailureReport type? #347

Open
thomasjm opened this issue Mar 6, 2018 · 4 comments
Open

Expose the FailureReport type? #347

thomasjm opened this issue Mar 6, 2018 · 4 comments

Comments

@thomasjm
Copy link

thomasjm commented Mar 6, 2018

In the current Hspec Config object there's a configFailureReport option, which causes Hspec to dump a FailureReport into a file. However, it seems to just use the Show instance of FailureReport, so the output is hard to work with given that FailureReport (the constructor and potential Read instance) isn't exposed anywhere.

This is especially needed since hspec-jenkins doesn't work with Hspec version 2, leaving limited ways to get detailed test failure information out for downstream CI stuff without writing a custom Formatter or something. (The Summary returned by hspecResult only has success/failure counts.)

@sol
Copy link
Member

sol commented Mar 11, 2018

Hey! Thanks for opening this issue and sorry for the late reply!

Currently the FailureReport type is used for rerunning failed tests (see https://hspec.github.io/rerun.html).

Let's look at that type:

data FailureReport = FailureReport {
  failureReportSeed :: Integer
, failureReportMaxSuccess :: Int
, failureReportMaxSize :: Int
, failureReportMaxDiscardRatio :: Int
, failureReportPaths :: [Path]
} deriving (Eq, Show, Read)

The first four fields are related to QuickCheck. The thing that may be of interest to you is failureReportPaths. This is basically a list of test cases that failed. E.g. with two failing test cases

describe "foo" $ do
  it "bar" ...
  it "baz" ...

failureReportPaths would be

[
  (["foo"], "bar")
, (["foo"], "baz")
]

Would it help your use case if you had access to this information?

@thomasjm
Copy link
Author

No worries, it seems I'm using all your packages haha.

Yes, the failureReportPaths is what I'm interested in.

@sol
Copy link
Member

sol commented Mar 13, 2018

@thomasjm Looking at again, I'm not comfortable with exposing Test.Hspec.Core.FailureReport in it's current form. What you can do as a workaround for now is defining

data FailureReport = FailureReport {
  failureReportSeed :: Integer
, failureReportMaxSuccess :: Int
, failureReportMaxSize :: Int
, failureReportMaxDiscardRatio :: Int
, failureReportPaths :: [Path]
} deriving (Eq, Show, Read)

in your own code for now and use that to read the failure report.

Is this a workable solution for you for now?

@sol sol added this to the 2.6.0 milestone Mar 14, 2018
@thomasjm
Copy link
Author

Sure, that works! It's not super urgent.

One other suggestion: it would be nice to add some more comments to the Haddocks on the Config constructor, since there's some useful stuff there but it's not totally clear what it all does. For example, both configFailureReport and configOutputFile accept a FilePath but I had to use trial and error to figure out what they each did.

@sol sol removed this from the 2.6.0 milestone May 8, 2019
@sol sol added this to the 2.8.0 milestone Apr 18, 2021
@sol sol modified the milestones: 2.8.0, later May 12, 2021
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