testcontainers-scala
testcontainers-scala copied to clipboard
support of weaver test framework
support of weaver test framework
this framework works best when a tested code is based on cats effect.
i'm keen to contribute
Hi @bwiercinski !
We are ready for contributions and could help you with this.
A few points I want you to have in mind:
- New API approach (from the current scalatest integration) will be more friendly for the weaver.
- It looks like the weaver can share resources across suites. It's a great feature for the testcontainers. Scalatest doesn't have a normal way of sharing containers across suites, which is unfortunate. It would be cool if you could use this feature in your integration layer.
Based on quick experimentation, it looks like the following snippet is all you need - it doesn't even need anything Weaver-specific, just a resource of a running container:
package com.dimafeng.testcontainers
import cats.effect.{Resource, Sync}
import cats.syntax.all._
object ContainerResource {
def apply[F[_], C <: Container](container: F[C])(implicit F: Sync[F]): Resource[F, C] =
Resource.make(container.flatTap {
container =>
F.blocking(container.start())
})(c => F.blocking(c.stop()))
}