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

How to test ? #486

Closed
leobenkel opened this Issue Dec 28, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@leobenkel
Copy link

leobenkel commented Dec 28, 2018

Hello,

I have been writing a project using Scalaz-Zio and using IO[A] throughout the project.

However, I am puzzled on how to write test for it.

How do I use assert(true, ...) when my value is IO[Error, Boolean] ?

Or assert(HaveSucceed, ...) ?

Thank you.

@ghostdogpr

This comment has been minimized.

Copy link
Contributor

ghostdogpr commented Dec 28, 2018

If your test class extends RTS, you can use unsafeRunSync on your IO to run it and receive an ExitResult[E, A] when it's completed. You can then use pattern matching on the ExitResult (or use toEither) to check if it was a success or failure.

You can also use unsafeRun directly to get an A but it will throw an exception in case of error.

@leobenkel

This comment has been minimized.

Copy link
Author

leobenkel commented Dec 28, 2018

Thank you !

@leobenkel leobenkel closed this Dec 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment