Packages

  • package root
    Definition Classes
    root
  • package org
    Definition Classes
    root
  • package scalatest

    ScalaTest's main traits, classes, and other members, including members supporting ScalaTest's DSL for the Scala interpreter.

    ScalaTest's main traits, classes, and other members, including members supporting ScalaTest's DSL for the Scala interpreter.

    Definition Classes
    org
  • package compatible
    Definition Classes
    scalatest
  • package concurrent

    Classes, traits, and objects related to testing asynchronous and multi-threaded behavior.

    Classes, traits, and objects related to testing asynchronous and multi-threaded behavior.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package diagrams

    A single traits and companion object that provides a assertions that draw code diagrams on failure.

    A single traits and companion object that provides a assertions that draw code diagrams on failure.

    This package is released as the scalatest-diagrams module.

    Definition Classes
    scalatest
  • DiagrammedExpr
  • Diagrams
  • package enablers

    Classes, traits, and objects for typeclasses that enable ScalaTest's DSLs.

    Classes, traits, and objects for typeclasses that enable ScalaTest's DSLs.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package events

    Classes for events sent to the org.scalatest.Reporter to report the results of running tests.

    Classes for events sent to the org.scalatest.Reporter to report the results of running tests.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package exceptions

    Classes and traits for exceptions thrown by ScalaTest.

    Classes and traits for exceptions thrown by ScalaTest.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package featurespec

    Classes and traits for ScalaTest's FeatureSpec style.

    Classes and traits for ScalaTest's FeatureSpec style.

    This package is released as the scalatest-featurespec module.

    Definition Classes
    scalatest
  • package fixture

    Classes and traits supporting ScalaTest's "fixture" style traits, which allow you to pass fixture objects into tests.

    Classes and traits supporting ScalaTest's "fixture" style traits, which allow you to pass fixture objects into tests.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package flatspec

    Classes and traits for ScalaTest's FlatSpec style.

    Classes and traits for ScalaTest's FlatSpec style.

    This package is released as the scalatest-flatspec module.

    Definition Classes
    scalatest
  • package freespec

    Classes and traits for ScalaTest's FreeSpec style.

    Classes and traits for ScalaTest's FreeSpec style.

    This package is released as the scalatest-freespec module.

    Definition Classes
    scalatest
  • package funspec

    Classes and traits for ScalaTest's FunSpec style.

    Classes and traits for ScalaTest's FunSpec style.

    This package is released as the scalatest-funspec module.

    Definition Classes
    scalatest
  • package funsuite

    Classes and traits for ScalaTest's FunSuite style.

    Classes and traits for ScalaTest's FunSuite style.

    This package is released as the scalatest-funsuite module.

    Definition Classes
    scalatest
  • package matchers

    Classes and traits for matchers.

    Classes and traits for matchers.

    This package is released as part of the scalatest-matchers-core module.

    Definition Classes
    scalatest
  • package prop
    Definition Classes
    scalatest
  • package propspec

    Classes and traits for ScalaTest's PropSpec style.

    Classes and traits for ScalaTest's PropSpec style.

    This package is released as the scalatest-propspec module.

    Definition Classes
    scalatest
  • package refspec

    Classes and traits for ScalaTest's RefSpec style.

    Classes and traits for ScalaTest's RefSpec style.

    This package is released as the scalatest-refspec module.

    Definition Classes
    scalatest
  • package tagobjects

    Singleton-object versions of ScalaTest's built-in tags.

    Singleton-object versions of ScalaTest's built-in tags.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package tags
    Definition Classes
    scalatest
  • package time

    Classes, traits, and objects for ScalaTest's time DSL.

    Classes, traits, and objects for ScalaTest's time DSL.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package tools

    Tools for running ScalaTest.

    Tools for running ScalaTest.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package verbs

    Classes and traits that support ScalaTest DSLs.

    Classes and traits that support ScalaTest DSLs.

    This package is released as part of the scalatest-core module.

    Definition Classes
    scalatest
  • package wordspec

    Classes and traits for ScalaTest's WordSpec style.

    Classes and traits for ScalaTest's WordSpec style.

    This package is released as the scalatest-wordspec module.

    Definition Classes
    scalatest
p

org.scalatest

diagrams

package diagrams

A single traits and companion object that provides a assertions that draw code diagrams on failure.

This package is released as the scalatest-diagrams module.

Source
package.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. diagrams
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. trait DiagrammedExpr[T] extends AnyRef

    A trait that represent an expression recorded by DiagrammedExprMacro, which includes the following members:

    A trait that represent an expression recorded by DiagrammedExprMacro, which includes the following members:

    • a boolean value
    • an anchor that records the position of this expression
    • anchor values of this expression (including sub-expressions)

    DiagrammedExpr is used by code generated from DiagrammedAssertionsMacro, it needs to be public so that the generated code can be compiled. It is expected that ScalaTest users would ever need to use DiagrammedExpr directly.

  2. trait Diagrams extends Assertions

    Sub-trait of Assertions that overrides assert and assume methods to include a diagram showing the values of expression in the error message when the assertion or assumption fails.

    Sub-trait of Assertions that overrides assert and assume methods to include a diagram showing the values of expression in the error message when the assertion or assumption fails.

    Here are some examples:

    scala> import org.scalatest.diagrams.Diagrams._
    import org.scalatest.diagrams.Diagrams._
    
    scala> assert(a == b || c >= d)
    org.scalatest.exceptions.TestFailedException:
    
    assert(a == b || c >= d)
           | |  | |  | |  |
           1 |  2 |  3 |  4
             |    |    false
             |    false
             false
    
            at org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:422)
            ...
    
    scala> assert(xs.exists(_ == 4))
    org.scalatest.exceptions.TestFailedException:
    
    assert(xs.exists(_ == 4))
           |  |
           |  false
           List(1, 2, 3)
    
            at org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:422)
            ...
    
    scala> assert("hello".startsWith("h") && "goodbye".endsWith("y"))
    org.scalatest.exceptions.TestFailedException:
    
    assert("hello".startsWith("h") && "goodbye".endsWith("y"))
           |       |          |    |  |         |        |
           "hello" true       "h"  |  "goodbye" false    "y"
                                   false
    
            at org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:422)
            ...
    
    scala> assert(num.isInstanceOf[Int])
    org.scalatest.exceptions.TestFailedException:
    
    assert(num.isInstanceOf[Int])
           |   |
           1.0 false
    
            at org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:422)
            ...
    
    scala> assert(Some(2).isEmpty)
    org.scalatest.exceptions.TestFailedException:
    
    assert(Some(2).isEmpty)
           |    |  |
           |    2  false
           Some(2)
    
            at org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:422)
            ...
    
    scala> assert(None.isDefined)
    org.scalatest.exceptions.TestFailedException:
    
    assert(None.isDefined)
           |    |
           None false
    
            at org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:422)
            ...
    
    scala> assert(xs.exists(i => i > 10))
    org.scalatest.exceptions.TestFailedException:
    
    assert(xs.exists(i => i > 10))
           |  |
           |  false
           List(1, 2, 3)
    
            at org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:422)
            ...
    
    

    If the expression passed to assert or assume spans more than one line, Diagrams falls back to the default style of error message, since drawing a diagram would be difficult. Here's an example showing how Diagrams will treat a multi-line assertion (i.e., you don't get a diagram):

    scala> assert("hello".startsWith("h") &&
         |   "goodbye".endsWith("y"))
    org.scalatest.exceptions.TestFailedException: "hello" started with "h", but "goodbye" did not end with "y"
            at org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:422)
            ...
    

    Also, since an expression diagram essentially represents multi-line ascii art, if a clue string is provided, it appears above the diagram, not after it. It will often also show up in the diagram:

    scala> assert(None.isDefined, "Don't do this at home")
    org.scalatest.exceptions.TestFailedException: Don't do this at home
    
    assert(None.isDefined, "Don't do this at home")
           |    |
           None false
    
            at org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:422)
            ...
    
    scala> assert(None.isDefined,
         |   "Don't do this at home")
    org.scalatest.exceptions.TestFailedException: Don't do this at home
    
    assert(None.isDefined,
           |    |
           None false
    
            at org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:422)
            ...
    

    Trait Diagrams was inspired by Peter Niederwieser's work in Spock and Expecty.

Value Members

  1. object DiagrammedExpr

    DiagrammedExpr companion object that provides factory methods to create different sub types of DiagrammedExpr

    DiagrammedExpr companion object that provides factory methods to create different sub types of DiagrammedExpr

    DiagrammedExpr is used by code generated from DiagrammedAssertionsMacro, it needs to be public so that the generated code can be compiled. It is expected that ScalaTest users would ever need to use DiagrammedExpr directly.

  2. object Diagrams extends Diagrams

    Companion object that facilitates the importing of Diagrams members as an alternative to mixing it in.

    Companion object that facilitates the importing of Diagrams members as an alternative to mixing it in. One use case is to import Diagrams members so you can use them in the Scala interpreter:

    $scala -classpath scalatest.jar
    Welcome to Scala version 2.10.4.final (Java HotSpot(TM) Client VM, Java 1.6.0_45).
    Type in expressions to have them evaluated.
    Type :help for more information.
     
    scala> import org.scalatest.Assertions._
    import org.scalatest.Assertions._
     
    scala> assert(1 === 2)
    org.scalatest.exceptions.TestFailedException:
    
    assert(1 === 2)
           | |   |
           1 |   2
             false
    
         at org.scalatest.Assertions$class.newAssertionFailedException(Assertions.scala:422)
    	    at org.scalatest.Diagrams$.newAssertionFailedException(Diagrams.scala:249)
    	    at org.scalatest.Diagrams$DiagramsHelper.macroAssert(Diagrams.scala:111)
    	    at .<init>(<console>:20)
    	    at .<clinit>(<console>)
    	    at .<init>(<console>:7)
    	    at .<clinit>(<console>)
     	  at $print(<console>)
    	    at sun.reflect.NativeMethodAccessorImpl.invoke...
    

Inherited from AnyRef

Inherited from Any

Ungrouped