Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Power assertions (as known from Groovy and Spock) for the Scala language.
Scala Shell Groovy
Branch: master
Failed to load latest commit information.
gradle/wrapper
m2repo/org/expecty/expecty release version 0.10
src only enable debug logging when system property `org.expecty.debug` is…
.gitignore added .gitignore
LICENSE added LICENCE, NOTICE, README.md; build improvements
NOTICE fixed NOTICE
README.md Update README.md
build.gradle update dependencies, bump version to 0.10
gradlew
gradlew.bat

README.md

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

Expecty is licensed under the Apache 2 license.

Latest Release

Expecty 0.10 was released on November 12th, 2013. It requires Scala 2.10.0 or higher.

Download

Get Expecty from its Maven repository at https://github.com/pniederw/expecty/tree/master/m2repo.

For sbt builds:

val expectyRepo = "Expecty Repository" at "https://raw.github.com/pniederw/expecty/master/m2repo/"
val expecty = "org.expecty" % "expecty" % "0.10"

For Gradle builds:

repositories {
  // important: this repo has to come last
  maven {
    name "expecty"
    url "https://raw.github.com/pniederw/expecty/master/m2repo/"
  }
}

dependencies {
  testCompile "org.expecty:expecty:0.10"
}

For Maven builds:

<repositories>
  <repository>
    <id>expecty</id>
    <url>https://raw.github.com/pniederw/expecty/master/m2repo/</url>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>org.expecty</groupId>
    <artifactId>expecty</artifactId>
    <version>0.10</version>
    <scope>test</scope>
  </dependency>
</dependencies>

Code Examples

import org.expecty.Expecty

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

val person = Person()
val expect = new Expecty()

// Passing expectations

expect {
  person.name == "Fred"
  person.age * 2 == 84
  person.say("Hi", "from", "Expecty!") == "Hi from Expecty!"
}

// Failing expectation

val word1 = "ping"
val word2 = "pong"

expect {
  person.say(word1, word2) == "pong pong"
}

/*
Output:

java.lang.AssertionError:

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

// Continue despite failing predicate

val expect2 = new Expecty(failEarly = false)

expect2 {
  person.name == "Frog"
  person.age * 2 == 73
}

/*
Output:

java.lang.AssertionError:

person.name == "Frog"
|      |    |
|      Fred false
Person(Fred,42)


person.age * 2 == 73
|      |   |   |
|      42  84  false
Person(Fred,42)
*/

Further Examples

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

Something went wrong with that request. Please try again.