Expecty

Power assertions (as known from Groovy and Spock) for the Scala language.

License

License

GroupId

GroupId

com.eed3si9n.expecty
ArtifactId

ArtifactId

expecty_0.16
Last Version

Last Version

0.12.0
Release Date

Release Date

Type

Type

jar
Description

Description

Expecty
Power assertions (as known from Groovy and Spock) for the Scala language.
Project URL

Project URL

https://github.com/eed3si9n/expecty
Project Organization

Project Organization

eed3si9n
Source Code Management

Source Code Management

https://github.com/eed3si9n/expecty

Download expecty_0.16

How to add to project

<!-- https://jarcasting.com/artifacts/com.eed3si9n.expecty/expecty_0.16/ -->
<dependency>
    <groupId>com.eed3si9n.expecty</groupId>
    <artifactId>expecty_0.16</artifactId>
    <version>0.12.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.eed3si9n.expecty/expecty_0.16/
implementation 'com.eed3si9n.expecty:expecty_0.16:0.12.0'
// https://jarcasting.com/artifacts/com.eed3si9n.expecty/expecty_0.16/
implementation ("com.eed3si9n.expecty:expecty_0.16:0.12.0")
'com.eed3si9n.expecty:expecty_0.16:jar:0.12.0'
<dependency org="com.eed3si9n.expecty" name="expecty_0.16" rev="0.12.0">
  <artifact name="expecty_0.16" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.eed3si9n.expecty', module='expecty_0.16', version='0.12.0')
)
libraryDependencies += "com.eed3si9n.expecty" % "expecty_0.16" % "0.12.0"
[com.eed3si9n.expecty/expecty_0.16 "0.12.0"]

Dependencies

compile (1)

Group / Artifact Type Version
ch.epfl.lamp : dotty-library_0.16 jar 0.16.0-RC3

test (1)

Group / Artifact Type Version
com.novocode : junit-interface jar 0.11

Project Modules

There are no modules declared in this project.

Expecty - Power Assertions for Scala

Expecty brings power assertions as known from Groovy and Spock to the Scala language. It is a micro library that aims to do one thing well.

License and Credits

Expecty was originally written by Peter Niederwieser, author of Spock.

Expecty is licensed under the Apache 2 license.

Setup

libraryDependencies += "com.eed3si9n.expecty" %% "expecty" % "0.12.0" % Test

Code Examples

Welcome to Scala 2.12.8 (OpenJDK 64-Bit Server VM, Java 1.8.0_212).
Type in expressions for evaluation. Or try :help.

scala> import com.eed3si9n.expecty.Expecty.assert
import com.eed3si9n.expecty.Expecty.assert

scala> case class Person(name: String = "Fred", age: Int = 42) {
     |   def say(words: String*) = words.mkString(" ")
     | }
defined class Person

scala> val person = Person()
person: Person = Person(Fred,42)

scala> // Passing expectations

scala> assert(person.name == "Fred")

scala> assert(person.age * 2 == 84)

scala> assert(person.say("Hi", "from", "Expecty!") == "Hi from Expecty!")

scala> // Failing expectation

scala> val word1 = "ping"
word1: String = ping

scala> val word2 = "pong"
word2: String = pong

scala> assert(person.say(word1, word2) == "pong pong")
java.lang.AssertionError: assertion failed

assert(person.say(word1, word2) == "pong pong")
       |      |   |      |      |
       |      |   ping   pong   false
       |      ping pong
       Person(Fred,42)

  at com.eed3si9n.expecty.Expecty$ExpectyListener.expressionRecorded(Expecty.scala:35)
  at com.eed3si9n.expecty.RecorderRuntime.recordExpression(RecorderRuntime.scala:39)
  ... 36 elided

scala> assert(person.age * 2 == 73, "age is not right")
java.lang.AssertionError: assertion failed: age is not right

assert(person.age * 2 == 73, "age is not right")
       |      |   |   |
       |      42  84  false
       Person(Fred,42)

  at com.eed3si9n.expecty.Expecty$ExpectyListener.expressionRecorded(Expecty.scala:35)
  at com.eed3si9n.expecty.RecorderRuntime.recordExpression(RecorderRuntime.scala:39)
  ... 36 elided

Further Examples

Have a look at ExpectySpec.scala and other specs in the same directory.

Versions

Version
0.12.0