A testing tool for Scala and Java developers
Scala Other
Switch branches/tags
release-3.0.5 release-3.0.4 release-3.0.3 release-3.0.2 release-3.0.0 release-3.0.0-SNAP2-for-scala-2.11-and-2.10 release-3.0.0-SNAP1-for-scala-2.11-and-2.10 release-3.0.0-RC4 release-3.0.0-RC3 release-3.0.0-RC3-for-scala-2.10-2.11-2.12 release-3.0.0-RC2-for-scala-2.10-2.11-2.12 release-3.0.0-RC1-with-scaladoc release-3.0.0-RC1-for-scala-2.11-and-2.10 release-3.0.0-M15-for-scala-2.11-and-2.10 release-3.0.0-M14-for-scala-2.11-and-2.10 release-3.0.0-M11-for-scala-2.11-and-2.10 release-3.0.0-M10-for-scala-2.11-and-2.10 release-3.0.0-M9-for-scala-2.11-and-2.10 release-3.0.0-M8 release-2.2.6-for-scala-2.11-and-2.10 release-2.2.6-M1-for-scala-2.11-and-2.10 release-2.2.5-for-scala-2.11-and-2.10 release-2.2.4-for-scala-2.11-and-2.10 release-2.2.3-SNAP1-for-scala-2.11-and-2.10 release-2.2.2-for-scala-2.11-and-2.10 release-2.2.1-for-scala-2.11-and-2.10 release-2.2.0-for-scala-2.11-and-2.10 release-2.2.0-RC2-for-scala-2.11-and-2.10 release-2.2.0-RC1-for-scala-2.11-and-2.10 release-2.2.0-M1-for-scala-2.10 release-2.1.7-for-scala-2.11 release-2.1.7-for-scala-2.10 release-2.1.6-for-scala-2.11 release-2.1.6-for-scala-2.10 release-2.1.5-for-scala-2.11 release-2.1.5-for-scala-2.10 release-2.1.4-for-scala-2.11 release-2.1.4-for-scala-2.10 release-2.1.3-for-scala-2.11.0-RC4 release-2.1.3-for-scala-2.11 release-2.1.3-for-scala-2.10 release-2.1.2-for-scala-2.11.0-RC3 release-2.1.2-for-scala-2.10 release-2.1.1-for-scala-2.11.0-RC2 release-2.1.1-for-scala-2.10 release-2.1.0-for-scala-2.11.0-RC1 release-2.1.0-for-scala-2.10 release-2.1.0-RC3-for-scala-2.11.0-M8 release-2.1.0-RC3-for-scala-2.10 release-2.1.0-RC2-for-scala-2.11.0-M8 release-2.1.0-RC2-for-scala-2.10 release-2.0.RC3-for-scala-2.10 release-2.0.RC2-for-scala-2.10 release-2.0.RC1-for-scala-2.10 release-2.0.M8-for-scala-2.10 release-2.0.M7-for-scala-2.10 release-2.0.M6-for-scala-2.10 release-2.0-for-scala-2.10 3.0.1
Nothing to show
Clone or download
Permalink
Failed to load latest commit information.
ant-lib initial version for github, created from current version of ScalaTest… Apr 9, 2013
common-test.js/src/main/scala Added the source code of parser combinators of current 1.0.x branch, … Dec 4, 2017
common-test.native/src/main/scala/org/scalatest Add generators specifically for native and work on compiling ScalaTes… Jul 26, 2017
common-test/src/main/scala Merge branch '3.1.x' into scala-native-support Dec 14, 2017
examples/src/test Latest 3.1.x Merge (#3) Oct 29, 2017
lib initial version for github, created from current version of ScalaTest… Apr 9, 2013
nbproject initial version for github, created from current version of ScalaTest… Apr 9, 2013
notes Changes to notes for 2.2.0 release. Jun 8, 2014
project Merge branch 'java-9' of https://github.com/ashawley/scalatest into a… May 27, 2018
scalactic-macro/src/main Replaced .size == 0 check with .isEmpty. Jan 29, 2018
scalactic-test/src/test/scala/org/scalactic Enhanced Prettifier to support ArrayOps. Dec 19, 2017
scalactic.js/src/main/scala/org/scalactic/source Ported over code form pretty-differ-2 branch, tests passed. Nov 11, 2017
scalactic/src/main Fixed shouldEqual problem when used with Accumulation's Combinable. Dec 19, 2017
scalatest-test/src Added aux constructor to ResultOfATypeInvocation, ResultOfAnTypeInvoc… Jun 2, 2018
scalatest.js/src/main/scala/org/scalatest Cherry-picked scala-js test count fix from 3.0.x branch. May 23, 2018
scalatest.native/src/main/scala/org/scalatest Ported test count fix in scala-js to scala-native. May 23, 2018
scalatest/src/main Added aux constructor to ResultOfATypeInvocation, ResultOfAnTypeInvoc… Jun 2, 2018
support Change scenariosFor to ScenariosFor Dec 13, 2016
webapp Added remaining html5 input tags Jul 14, 2013
.gitattributes Added .gitattributes file that contains settings to use unix-style EOL. Apr 9, 2013
.gitignore Add generators specifically for native and work on compiling ScalaTes… Jul 26, 2017
.jvmopts Drop CMSIncrementalMode from .jvmopts for Java 9 Mar 23, 2018
.travis.yml Simplify travis_build.sh May 28, 2018
2.9_excludes Renamed scalautils to scalactic. Apr 24, 2014
LICENSE initial version for github, created from current version of ScalaTest… Apr 9, 2013
NOTICE initial version for github, created from current version of ScalaTest… Apr 9, 2013
README.md Merge pull request #1357 from ashawley/travis-badge May 28, 2018
addmem.sh initial version for github, created from current version of ScalaTest… Apr 9, 2013
build.xml Removed the use of no-specialization in both ant and sbt build. May 14, 2014
migration.txt initial version for github, created from current version of ScalaTest… Apr 9, 2013
osgi.bnd Renamed scalautils to scalactic. Apr 24, 2014
pom_template.xml Fix OSGi tests Apr 10, 2014
scalactic-osgi.bnd Renamed scalautils to scalactic. Apr 24, 2014
scalactic-pom_template.xml Renamed scalautils to scalactic. Apr 24, 2014
todo.txt Renamed Spec and SpecLike to RefSpec and RefSpecLike, moved them into… Nov 13, 2015
travis_build.sh Add back echo for genGenTests May 28, 2018
updateCopyright.bash added bash script to update Copyright to current year and added all j… Aug 29, 2013
use-ldquo-and-rdquo.bash script to replace “ with “ and ” with ” and r… Sep 8, 2013

README.md

ScalaTest

Build Status

ScalaTest is a free, open-source testing toolkit for Scala and Java programmers.

Official Website: http://www.scalatest.org/

Using ScalaTest

Setup

Please visit Download and Setup for download and setup instructions.

Quick Start

Please visit Quick Start for steps to get started quickly.

Building ScalaTest

Pre-Requisites

The followings are needed for building ScalaTest:

for JDK 6 or 7, use the following options in your SBT launch file:

SBT_OPTS="-server -Xms512M -Xmx3000M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:NewRatio=8 -XX:MaxPermSize=512M"

for JDK 8 or 9, use the following SBT options instead:

SBT_OPTS="-server -Xms512M -Xmx3000M -Xss1M  -XX:+UseConcMarkSweepGC -XX:NewRatio=8"

Building and Running Tests

This command will build and run the regular tests:

$ sbt test

To run generated all tests, you'll need to increase maximum heap size to at least -Xmx5000M, and use this command instead:

$ rm -rf gentests
$ sbt gentests/test

You can also run different groups generated tests separately:

$ rm -rf gentests
$ sbt genMustMatchersTests1/test
$ sbt genMustMatchersTests2/test
$ sbt genMustMatchersTests3/test
$ sbt genMustMatchersTests4/test
$ sbt genGenTests/test
$ sbt genTablesTests/test
$ sbt genInspectorsTests/test
$ sbt genInspectorsShorthandsTests1/test
$ sbt genInspectorsShorthandsTests2/test
$ sbt genTheyTests/test
$ sbt genContainTests1/test
$ sbt genContainTests2/test
$ sbt genSortedTests/test
$ sbt genLoneElementTests/test
$ sbt genEmptyTests/test

What it does is simply switch to gentests project and run test.

To run scala-js tests:

$ sbt scalatestAppJS/clean
$ sbt scalacticTestJS/test:compile
$ sbt scalacticTestJS/test
$ sbt scalatestTestJS/test:compile
$ sbt scalatestTestJS/test

To run scala-native tests:

$ sbt -Dscalatest.skip.jdk.check=true ++2.11.12 scalatestAppNative/clean
$ sbt -Dscalatest.skip.jdk.check=true ++2.11.12 scalacticTestNative/test:compile
$ sbt -Dscalatest.skip.jdk.check=true ++2.11.12 scalacticTestNative/test
$ sbt -Dscalatest.skip.jdk.check=true ++2.11.12 scalatestTestNative/test:compile
$ sbt -Dscalatest.skip.jdk.check=true ++2.11.12 scalatestTestNative/test

Building Exmaples

You can build examples project using this command:

$ sbt examples/compile

Packaging

You can package the ScalaTest JAR file using this command:

$ sbt package

The resulting JAR file will be produced in target/scala-2.11/.

You can also publish it to your local Ivy repository using this command:

$ sbt publishLocal

Or publish it to local maven repository using this command:

$ sbt publishM2

Publishing

To publish to Sonatype, you first need to make sure you have the following:

  • A GPG client is installed on your command line path. For more information, please refer to GNU Privacy Guard Website.
  • You have created your GPG keys and distributed your public key to hkp://pool.sks-keyservers.net/. For more information, please refer to How To Generate PGP Signatures With Maven.
  • You have been granted the right to publish using org.scalatest and org.scalactic domain.

By default, ScalaTest build will read your Sonatype credentials from ~/.ivy2/.credentials, which is a properties file that looks like this:

realm=Sonatype Nexus Repository Manager
host=oss.sonatype.org
user=xxxxxxxx
password=xxxxxxxx

You can use SCALATEST_NEXUS_LOGIN and SCALATEST_NEXUS_PASSWORD environment variables to override Sonatype credentials.

For signing, ScalaTest build will use ~/.gnupg/secring.gpg by default and prompt for GPG passphase if required. Alternatively you can use SCALATEST_GPG_FILE to use a different GPG file, and use SCALATEST_GPG_PASSPHASE to provide GPG passphase to avoid input prompt.

If you would like to export a particular private key into a separate GPG file, you can use the following command:

$ gpg --export-secret-keys example@example.com > example-secret-key.gpg

With Sonatype credentials and GPG file in place, you can now publish to Sonatype.

Before publishing any patch release, binary compatibility with previous version should be checked, using Java 6 (for Scala 2.10 and 2.11):

$ sbt ++2.11.12 scalactic/package scalactic/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatest/package scalatest/mimaReportBinaryIssues
$ sbt ++2.11.12 scalacticJS/package scalacticJS/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestJS/package scalatestJS/mimaReportBinaryIssues

$ sbt ++2.10.7 scalactic/package scalactic/mimaReportBinaryIssues
$ sbt ++2.10.7 scalatest/package scalatest/mimaReportBinaryIssues
$ sbt ++2.10.7 scalacticJS/package scalacticJS/mimaReportBinaryIssues
$ sbt ++2.10.7 scalatestJS/package scalatestJS/mimaReportBinaryIssues

and using Java 8 (for Scala 2.12 and 2.13):

$ sbt ++2.12.4 scalactic/package scalactic/mimaReportBinaryIssues
$ sbt ++2.12.4 scalatest/package scalatest/mimaReportBinaryIssues
$ sbt ++2.12.4 scalacticJS/package scalacticJS/mimaReportBinaryIssues
$ sbt ++2.12.4 scalatestJS/package scalatestJS/mimaReportBinaryIssues

$ sbt ++2.13.0-M2 scalactic/package scalactic/mimaReportBinaryIssues
$ sbt ++2.13.0-M2 scalatest/package scalatest/mimaReportBinaryIssues
$ sbt ++2.13.0-M2 scalacticJS/package scalacticJS/mimaReportBinaryIssues
$ sbt ++2.13.0-M2 scalatestJS/package scalatestJS/mimaReportBinaryIssues

To publish scalactic, scalatest and scalatest-app (for Scala and Scala-js, version 2.11 and 2.10, and make sure you're on Java 6) to Sonatype, use the following command:

$ sbt ++2.11.12 clean publishSigned "project scalatestAppJS" clean publishSigned ++2.10.7 "project scalatestApp" clean publishSigned "project scalatestAppJS" clean publishSigned

To publish scalactic, scalatest and scalatest-app (for Scala and Scala-js, version 2.12 and 2.13, and make sure you're on Java 8) to Sonatype, use the following command:

$ sbt ++2.12.4 clean publishSigned "project scalatestAppJS" clean publishSigned ++2.13.0-M2 clean publishSigned "project scalatestAppJS" clean publishSigned

To publish scalactic, scalatest and scalatest-app (for Scala-native version 2.11, and make sure you're on Java 8) to Sonatype, use the following command:

$ sbt -Dscalatest.skip.jdk.check=true ++2.11.12 "project scalatestAppNative" clean publishSigned