Тестовое использование scalatest не компилируется

У меня есть пример теста, в котором используется черта PropertyChecks:

import org.scalatest.prop.PropertyChecks
import org.scalatest.{Matchers, PropSpec}

class AppTest extends PropSpec with PropertyChecks with Matchers {
  val invalidCombos =
    Table(
      ("str", "val"),
      ("1", 1)
    )

  forAll(invalidCombos) { (n: String, d: Int) =>
    val i: Int = Integer.parseInt(n)
    whenever(n.length != 0) {
      i should be(d)
    }
  }
}

Это дает следующую ошибку:

[ERROR] /home/atcvetkov/project/dummy/dummy-scala/src/test/scala/dummy/AppTest.scala:13: error: Symbol 'type org.scalacheck.Gen' is missing from the classpath.
[INFO] This symbol is required by 'value org.scalatest.prop.GeneratorDrivenPropertyChecks.genAndNameA'.
[INFO] Make sure that type Gen is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
[INFO] A full rebuild may help if 'GeneratorDrivenPropertyChecks.class' was compiled against an incompatible version of org.scalacheck.
[INFO]   forAll(invalidCombos) { (n: String, d: Int) =>
[INFO]   ^
[ERROR] one error found

Я проверил и обнаружил, что в моем пути к классам нет org.scalacheck.Gen.

Я использую следующую зависимость maven:

<dependency>
    <groupId>org.scalatest</groupId>
    <artifactId>scalatest_2.12</artifactId>
    <scope>test</scope>
    <version>3.0.5</version>
</dependency>

person talex    schedule 12.06.2018    source источник


Ответы (1)


Вам также необходимо добавить зависимость для scalacheck в дополнение к scalatest:

<dependency>
    <groupId>org.scalacheck</groupId>
    <artifactId>scalacheck_2.12</artifactId>
    <scope>test</scope>
    <version>1.14.0</version>
</dependency>
person vdebergue    schedule 12.06.2018
comment
Спасибо. Интересно, почему у scalatest нет этой зависимости. - person talex; 12.06.2018
comment
Я предполагаю, что идея состоит в том, чтобы убрать его из пути к классам, за исключением проектов, где фактически используется интеграция scalacheck. - person Seth Tisue; 12.06.2018