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

How to test ? #486

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

How to test ? #486

leobenkel opened this issue Dec 28, 2018 · 2 comments

Comments

@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
Copy link
Member

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
Copy link
Author

Thank you !

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

2 participants