NorfairKing / sydtest

A modern testing framework for Haskell with good defaults and advanced testing features.
113 stars 25 forks source link

Filter branches and multiple tests in one command? #62

Closed mrcjkb closed 1 year ago

mrcjkb commented 1 year ago

Given the following test tree:

describe "Prelude.head" $ do
  -- <some other tests>
  specify "Returns the first element of a list" $ 
    property $ \x xs ->
      head (x : xs) `shouldBe` (x :: Int)

describe "Prelude.tail" $ do
  -- <some other tests>
  describe "Single element list" $
    specify "Returns the empty list" $ 
      property $ \x -> tail [x :: Int] `shouldBe` []

describe "Some other tests" $
-- ...

With hspec, I can call

cabal test --test-option -m --test-option "/Prelude.head/" --test-option -m --test-option "/Prelude.tail/" 

...to filter by both the "Prelude.head" and "Prelude.tail" paths in one test run.

And I can call

cabal test --test-option -m --test-option "/Prelude.head/Returns the first element of a list/"

...to run only the "Returns the first element of a list" branch (in case there are additional branches under "Prelude.head").

Is this possible with sydtest?

mrcjkb commented 1 year ago

Running only the "Returns the first element of a list" branch seems to work if I separate branches with a .

cabal test --test-option "--match" --test-option "Prelude.head.Returns the first element of a list"
NorfairKing commented 1 year ago

@mrcjkb There's currently no "or" for the matches but that'd be welcome!

mrcjkb commented 1 year ago

Do you prefer the hspec approach: --match "path.to.test.a" --match "path.to.test.b" or the tasty approach, where the filter is an awk expression?

My personal opinion:

hspec approach

tasty approach

NorfairKing commented 1 year ago

@mrcjkb Multiple matches sounds simpler to me indeed. I also don't want to depend on awk tbh. What do you think?

mrcjkb commented 1 year ago

tasty's parser doesn't depend on awk.

But I agree. I think I prefer the simpler solution. It can always be extended if the need comes up one day.