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

Async before and after #953

Closed
LMnet opened this issue Aug 10, 2016 · 12 comments
Closed

Async before and after #953

LMnet opened this issue Aug 10, 2016 · 12 comments

Comments

@LMnet
Copy link

LMnet commented Aug 10, 2016

It is more feature request, than issue.
ATM all before and after stuff is fully synchronous: all methods returns Unit. It would be good to have a possibility to have an asynchronous versions of this methods. Typical use case for this async methods: operations with DB. For now i'm forced to use Await.ready to block my async operations.
I can suggest two options for the implementation:

  1. Add extra methods into existent traits.
  2. Add new traits, like BeforeAndAfterAllAsync.

Personally, I prefer the first way.

@cheeseng
Copy link
Contributor

Hi @LMnet , in 3.0 we have made BeforeAndAfter and BeforeAndAfterAll to work with async style trait, I wonder if they fit your use case?

@LMnet
Copy link
Author

LMnet commented Aug 24, 2016

I'm using 3.0 version with AsyncFreeSpec. But in BeforeAndAfterAll beforeAll and afterAll methods are synchronuous. I checked run method in BeforeAndAfterAll and I didn't find any async stuff there. If my action inside beforeAll or afterAll returns Future, I want to wait until it finished.

@bvenners
Copy link
Contributor

@LMnet That's done here:

https://github.com/scalatest/scalatest/blob/3.0.x/scalatest/src/main/scala/org/scalatest/BeforeAndAfterAll.scala#L223

The withAfterEffect method registers the afterAll code to run as an effect after the Status returned by super.run completes. The Status is kind of like a Future[Boolean].

@LMnet
Copy link
Author

LMnet commented Oct 23, 2016

@bvenners But what about before? withAfterEffect could replace only after method. And using this method looks like hack for me.

@jhegedus42
Copy link

Is this issue solved already ?

I put up a related SOF question:
https://stackoverflow.com/questions/46584633/async-before-in-scalatest-for-scalajs

@harmeetsingh0013
Copy link

What exactly the solution for this ticket? I have requirements, where we need to call multiple future calls in the beforeAll method.

@bvenners
Copy link
Contributor

We haven't done anything with beforeAll. Let me think about if that is possible, and if so how best to go about it.

@bilal-fazlani
Copy link

What's the status of this issue?

@ThijsBroersen
Copy link

I am also in need of an async beforeAll. Have not found any solution which does not include blocking (which is not possible in Scala.js).

@espetro
Copy link

espetro commented Feb 4, 2021

Hi there! Is this issue already solved? I am also interested in it for Scala in JVM

@harpocrates
Copy link

How is this issue closed? Even if there's a workaround for an asynchronous afterAll, there's still no way to have asynchronous beforeAll.

Should I open a new issue?

@mirelon
Copy link

mirelon commented Apr 7, 2022

Please reopen this issue as there is no possibility to execute asynchronous code in beforeAll()

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

10 participants