scoped-fixtures


License

License

GroupId

GroupId

com.spingo
ArtifactId

ArtifactId

scoped-fixtures_2.12
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

scoped-fixtures
scoped-fixtures
Project URL

Project URL

https://github.com/SpinGo/scoped-fixtures
Project Organization

Project Organization

com.spingo
Source Code Management

Source Code Management

https://github.com/SpinGo/scoped-fixtures

Download scoped-fixtures_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/com.spingo/scoped-fixtures_2.12/ -->
<dependency>
    <groupId>com.spingo</groupId>
    <artifactId>scoped-fixtures_2.12</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.spingo/scoped-fixtures_2.12/
implementation 'com.spingo:scoped-fixtures_2.12:2.0.0'
// https://jarcasting.com/artifacts/com.spingo/scoped-fixtures_2.12/
implementation ("com.spingo:scoped-fixtures_2.12:2.0.0")
'com.spingo:scoped-fixtures_2.12:jar:2.0.0'
<dependency org="com.spingo" name="scoped-fixtures_2.12" rev="2.0.0">
  <artifact name="scoped-fixtures_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.spingo', module='scoped-fixtures_2.12', version='2.0.0')
)
libraryDependencies += "com.spingo" % "scoped-fixtures_2.12" % "2.0.0"
[com.spingo/scoped-fixtures_2.12 "2.0.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.1
org.scalatest : scalatest_2.12 jar 3.0.1

Project Modules

There are no modules declared in this project.

Scoped Fixtures

Compatible with scala-test 3.0.x; Scala 2.11 and 2.12.

Installing

libraryDependencies += "com.spingo" %% "scoped-fixtures" % "2.0.0"

About

For stateful values that re-initialize on each run.

Fixture Types:

ScopedFixtures provides 3 different kinds of fixtures:

  • LazyFixture
  • EagerFixture
  • ScopedFixture

LazyFixture

This value gets instantiated on the first access for each test.

Example:

val lazyValue = LazyFixture {
  new MutableThing
}

EagerFixture

Like LazyFixture, but is instantiated for each test whether it's accessed or not.

ScopedFixture

Helpful for providing values that have needs setup and tear-down:

val actorSystemFixture = ScopedFixture[ActorSystem] { provide =>
  val actorSystem = ActorSystem("test")
  val status = provide(actorSystem)
  actorSystem.shutdown
  status
}

Dereferencing

The value assigned to val is a container; in order to get the actual value, you must call apply(). IE:

val actorSystemFixture = ScopedFixture[ActorSystem] { provide =>
  val actorSystem = ActorSystem("test")
  val status = provide(actorSystem)
  actorSystem.shutdown
  status
}
implicit def actorSystem = actorSystemFixture()
com.spingo

SpinGo

Versions

Version
2.0.0