Delete project/plugins directory if it exists and edit project/plugins.sbt as follows:
addSbtPlugin("com.github.seratch" %% "testgenerator" % "1.1.1")
testgeneratorSettings
See also: https://github.com/harrah/xsbt/wiki/Setup
src/main/scala/com/example/models.scala:
package com.example
case class Staff(id: Long, name: String, ...)
case class Company(id: Long, name: String, ...)
case class Stock(id: Long, itemId: Long, ...)
And specify the above file:
$ sbt
> test-gen com/example/models.scala
"com.example.StaffSpec" already exists.
"com.example.CompanySpec" already exists.
"com.example.StockSpec" created.
If you specify a class name, it must be the name of the source file.
"com.example.MyApp" will be translated as "src/main/scala/com/example/MyApp.scala".
$ sbt
> test-gen com.example.MyApp
"com.example.MyAppSpec" created.
"test-gen" will search targets recursively under the directory.
$ sbt
> test-gen com/example
The same as specifying a directory.
$ sbt
> test-gen com.example
"com.example.MyAppSpec" created.
"com.example.util.MyUtilSpec" created.
Please add the following line at the top of your buid.sbt:
import testgenerator.SbtKeys._
and then,
testgeneratorSettings
testgeneratorEncoding in Compile := "UTF-8"
testgeneratorTestTemplate in Compile := "scalatest.FlatSpec"
testgeneratorScalaTestMatchers in Compile := "ShouldMatchers"
testgeneratorWithJUnitRunner in Compile := false
testgeneratorLineBreak in Compile := "LF"
- "scalatest.FunSuite"
- "scalatest.Assertions"
- "scalatest.Spec"
- "scalatest.WordSpec"
- "scalatest.FlatSpec" (default)
- "scalatest.FeatureSpec"
- "specs.Specification"
- "specs2.Specification"
- "ShouldMatchers" (default)
- "MustMatchers"
- "" (empty)