Skip to content

Commit 00ddd7c

Browse files
Merge pull request #1178 from mdipirro/scala-671
SCALA-671 Add code for ZIO Aspects in tests
2 parents bf71295 + f9573b2 commit 00ddd7c

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

build.sbt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,16 @@ lazy val zio = (project in file("zio"))
593593
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")
594594
)
595595

596+
lazy val zio2 = (project in file("zio-2"))
597+
.settings(
598+
name := "zio-2",
599+
scalaVersion := scala3Version,
600+
libraryDependencies += "dev.zio" %% "zio" % zioVersion,
601+
libraryDependencies += "dev.zio" %% "zio-test" % zioVersion % Test,
602+
libraryDependencies += "dev.zio" %% "zio-test-sbt" % zioVersion % Test,
603+
testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework")
604+
)
605+
596606
lazy val zio3 = (project in file("zio3"))
597607
.settings(
598608
libraryDependencies ++= Seq(
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.baeldung.scala.zio.aspects
2+
3+
import com.baeldung.scala.zio.aspects.ZAspectsSpec.test
4+
import zio.*
5+
import zio.test.*
6+
import zio.test.TestAspect.{aroundWith, ignore, nonFlaky, timeout}
7+
8+
object ZAspectsSpec extends ZIOSpecDefault {
9+
override def spec = suite("ZAspectSpec")(
10+
test("Tautology test") {
11+
assertTrue(true)
12+
},
13+
test("Tautology test") {
14+
assertTrue(true)
15+
} @@ ignore,
16+
test("Run effects around a test") {
17+
for {
18+
plt <- System.env("PLATFORM")
19+
} yield assertTrue(plt.contains("Baeldung"))
20+
} @@ aroundWith {
21+
val platform = "Baeldung"
22+
TestSystem.putEnv("PLATFORM", platform) *> ZIO.succeed(platform)
23+
}(envVar => ZIO.debug(s"Platform: $envVar")),
24+
test("Non flaky") {
25+
assertTrue(true)
26+
} @@ nonFlaky(10)
27+
/* Commented out as otherwise the test suite will fail
28+
test("timeouts") {
29+
for {
30+
_ <- ZIO.succeed("Baeldung").forever
31+
} yield assertTrue(true)
32+
} @@ timeout(1.second)*/
33+
)
34+
}

0 commit comments

Comments
 (0)