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

Concerns about elm-check integration #19

Open
mgold opened this issue Jun 17, 2015 · 2 comments
Open

Concerns about elm-check integration #19

mgold opened this issue Jun 17, 2015 · 2 comments

Comments

@mgold
Copy link

mgold commented Jun 17, 2015

Hi Hassan,

I'm testing my non-empty list library and I'm adding a function that's really hard to write properties for so I'm using unit tests. I looked at the elm-test integration and, even with the README, it looks way too complicated. What I'd really like is f : Test -> Claim so I can just stick my unit tests into my property tests and call it a day. Instead I wound up hacking the output of the two libraries together. Not ideal, but it's just testing (and not even CI). Am I missing an easy way to make this work, or is there any chance you can put f on the radar?

Here is the new commit that caused all this.

@TheSeamau5
Copy link
Owner

Yeah, I've been thinking on how to add this but I couldn't figure out the best way. Currently, Check and Check.Test are really like two seperate libraries. You can't use one alongside the other in a meaningful way. The reason behind this is because with Check.Test you want to generate a given number of unit tests whereas with Check you want to find just 1 failing test (theoretically, you should be able to run this process of hunting for a failing test forever).

I haven't figured out the best way to do this. But, ideally, Claim would be super generic and you could plug-in whatever you want on top of it.

So, to answer your question, yes, it has been on the radar from day one. Basically, the elm-test support that's currently here is just there cuz it's better than nothing. You get to re-use your investigators and you still get shrinking. But, different functions, different data structures, and different number of parameters so you have to slightly re-write your tests.

By the way, if you've got an idea on how to improve things, please don't hesitate. This is totally open source and I take PRs and I'm far from being an expert on testing.

@rtfeldman
Copy link
Contributor

For what it's worth, when I use elm-check from within elm-test I use this helper function:

runCount = 100
seed = 1337

it : String -> (a -> b) -> (a -> b) -> Investigator a -> Test
it description expected actual investigator =
  Check.Test.test description actual expected investigator runCount seed

Then you can write stuff like:

suite "List.reverse" [
    it "is a no-op when applied twice"
      (identity)
      (List.reverse >> List.reverse)
      (list string)
  ]

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

3 participants