zio-test-macros


License

License

GroupId

GroupId

com.timushev
ArtifactId

ArtifactId

zio-test-macros_sjs1_2.13
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

zio-test-macros
zio-test-macros
Project URL

Project URL

https://github.com/rtimush/zio-test-macros
Project Organization

Project Organization

com.timushev
Source Code Management

Source Code Management

https://github.com/rtimush/zio-test-macros

Download zio-test-macros_sjs1_2.13

How to add to project

<!-- https://jarcasting.com/artifacts/com.timushev/zio-test-macros_sjs1_2.13/ -->
<dependency>
    <groupId>com.timushev</groupId>
    <artifactId>zio-test-macros_sjs1_2.13</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.timushev/zio-test-macros_sjs1_2.13/
implementation 'com.timushev:zio-test-macros_sjs1_2.13:0.1.0'
// https://jarcasting.com/artifacts/com.timushev/zio-test-macros_sjs1_2.13/
implementation ("com.timushev:zio-test-macros_sjs1_2.13:0.1.0")
'com.timushev:zio-test-macros_sjs1_2.13:jar:0.1.0'
<dependency org="com.timushev" name="zio-test-macros_sjs1_2.13" rev="0.1.0">
  <artifact name="zio-test-macros_sjs1_2.13" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.timushev', module='zio-test-macros_sjs1_2.13', version='0.1.0')
)
libraryDependencies += "com.timushev" % "zio-test-macros_sjs1_2.13" % "0.1.0"
[com.timushev/zio-test-macros_sjs1_2.13 "0.1.0"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.13.4
org.scala-js : scalajs-library_2.13 jar 1.3.1
dev.zio : zio-test_sjs1_2.13 jar 1.0.3

provided (2)

Group / Artifact Type Version
org.scala-lang : scala-compiler jar 2.13.4
org.scala-lang : scala-reflect jar 2.13.4

test (2)

Group / Artifact Type Version
org.scala-js : scalajs-test-bridge_2.13 jar 1.3.1
dev.zio : zio-test-sbt_sjs1_2.13 jar 1.0.3

Project Modules

There are no modules declared in this project.

ZIO test macros

This micro-library lets you use a more concise ZIO assertion syntax for class fields:

import com.timushev.zio.test.macros.Assertion._

assert(book)(hasPath(_.author.name, isNonEmptyString))

Comparing to the default hasField combinator, hasPath does not make you duplicate the field name:

assert(book)(hasField("author.name", _.author.name, isNonEmptyString))

A compiler macro captures the field names for you, so in case of a failure the error message is still informative:

// com.timushev.zio.test.macros.Assertion.hasPath
Book(Writer()) did not satisfy hasPath(_.author.name, isNonEmptyString())

// zio.test.Assertion.hasField
Book(Writer()) did not satisfy hasField("author.name", _.author.name, isNonEmptyString())

Usage

The library is cross-built for Scala 2.12 and 2.13, both JVM and Scala.js 1.0 platforms. It is published to Maven Central, so you just need to add the following to your build.sbt:

libraryDependencies += "com.timushev" %% "zio-test-macros"  % "0.1.0"

Credits

Macro implementation is inspired by Monocle.

Versions

Version
0.1.0