UnkindPartition / tasty

Modern and extensible testing framework for Haskell
640 stars 110 forks source link

[Question / Feature Request] Origin of TestCase #397

Closed lapplislazuli closed 1 year ago

lapplislazuli commented 1 year ago

Hi,

I am currently working a bit with Tasty TestTrees and I am lacking the option to pattern-match for the origin of a test. I would like to be able to iterate over the tests and do different behavior for HUnit,QuickCheck or SmallCheck tests. Maybe I just missed something in the implementations or don't know a good Haskell feature, but I think it would be a small change that could help a variety of downstream tools (but I guess not many users directly).

Basically I would love to have a function showOrigin :: TestTree -> Text where Text is one of HUnit, QuickCheck, etc.

Bodigrim commented 1 year ago

@lapplislazuli see https://hackage.haskell.org/package/base-4.16.3.0/docs/Data-Typeable.html#v:typeOf. Is it sufficient for your purposes?

lapplislazuli commented 1 year ago

Hi @Bodigrim thanks for your answer! I think this will not do, because all Tests have the same type TestTree ? Or am I missing something?

Bodigrim commented 1 year ago

You are expected to unwrap SingleTest and look at t inside of it.

lapplislazuli commented 1 year ago

Thank you very much! That was the perfect hint I needed.