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

Add assertion combinators #8

Closed
ghost opened this issue May 4, 2017 · 2 comments
Closed

Add assertion combinators #8

ghost opened this issue May 4, 2017 · 2 comments

Comments

@ghost
Copy link

ghost commented May 4, 2017

There is a lot of cases where I want to write something like this:

        test "Barray.set" (fun () ->
            let arr = [|1; 2; 3|] in
            let b = Barray.set 1 3 arr in
            Expect.toEqual b true `and` Expect.toEqual arr [|1; 3; 3|]
        );

So we can combine two assertions into one. Do you think this is possible? @glennsl

Thanks!

@glennsl
Copy link
Owner

glennsl commented May 4, 2017

The thought has certainly crossed my mind, but I haven't really found any good use cases for it. Not that I've really looked all that much. Requiring a single assertion per test encourages simple tests, and I think your specific case here is a good example of that since it's trying to test two different properties at once.

I think it's good practice to design your tests around the properties you'd like tested instead of just "coverage".

@glennsl
Copy link
Owner

glennsl commented Dec 18, 2017

After some more thought and experience, I think enforcing a single assertion per test is still the right approach. Support for generating tests based on a set of test cases was added with testAll in #12, however, and might relieve some of the need you feel for combinators.

I'll close this for now, reopen if you find a scenario where you think the current tools are insufficient.

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

1 participant