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 @@ withLiveClock to documentation #8843

Open
wants to merge 11 commits into
base: series/2.x
Choose a base branch
from

Conversation

mobley-trent
Copy link

/claim #8735
closes #8735

@CLAassistant
Copy link

CLAassistant commented May 11, 2024

CLA assistant check
All committers have signed the CLA.

@mobley-trent mobley-trent marked this pull request as ready for review May 12, 2024 11:48
@jdegoes
Copy link
Member

jdegoes commented May 12, 2024

@mobley-trent These comments are mostly not true.

And, to the extent they are true, they are not relevant.

withLiveClock allows you to run a test with the live, rather than test clock. The test clock is nice for testing but requires you advance time manually. Sometimes, people need a real clock for their tests, rather than a test one, and this is what withLiveClock (etc.) are designed to allow.

@jdegoes jdegoes requested a review from khajavi May 12, 2024 17:41
@mobley-trent
Copy link
Author

@jdegoes thanks for the insights. I think I covered that information in my comments. Is there something I missed ?

@@ -24,3 +24,6 @@ println("""```scala""")
println("""testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")""")
println("""```""")
```


**NOTE**: Default services were removed from the ZIO environment in ZIO 2.x and integrated into the ZIO runtime. This also brings some changes to the way we run tests using these services. In order to use the live version of these services in our tests, we can use some new helpful test aspects e.g `withLiveClock`, `withLiveConsole`, `withLiveRandom`, `withLiveSystem`, etc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of discussing changes in ZIO 2.x, focus on the current features. If you need to address changes, consider including them in the migration guides, such as "ZIO 2.x Migration Guide".


### Example 5

In ZIO 2.x, we can use the live `Clock` service from the ZIO runtime in our tests using the `withLiveClock` test aspect. This removes the need to advance `TestClock` manually in our tests:
Copy link
Member

@khajavi khajavi May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In ZIO 2.x, we can use the live `Clock` service from the ZIO runtime in our tests using the `withLiveClock` test aspect. This removes the need to advance `TestClock` manually in our tests:
We can use the live `Clock` service from the ZIO runtime in our tests using the `withLiveClock` test aspect. This removes the need to advance `TestClock` manually in our tests:

Copy link
Member

@khajavi khajavi May 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This removes the need to advance TestClock manually in our tests

Because we need to advance the clock both manually and lively, I suggest including a section that explains the difference between TestClock and a live clock, and when it is appropriate to use a live clock and when test clocks for testing components.

@mobley-trent
Copy link
Author

@mobley-trent mobley-trent requested a review from khajavi May 16, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add TestAspect.withLiveClock to the docs
4 participants