Specs2 mockito throws NoSuchMethodError

80 views Asked by At

I have a Scala project based on play framework. I am using specs2 mockito and specifications for test cases. When running the test cases, I am getting following error:

Exception in thread "specs2-7" java.lang.NoSuchMethodError: 'scala.collection.immutable.Stream org.specs2.data.Trees$Treex.flattenLeft()'
  | => cat org.specs2.reporter.JUnitDescriptions.fragmentDescriptions(JUnitDescriptions.scala:69)
    at org.specs2.reporter.JUnitDescriptions.fragmentDescriptions$(JUnitDescriptions.scala:68)
    at org.specs2.reporter.JUnitDescriptions$.fragmentDescriptions(JUnitDescriptions.scala:115)
    at org.specs2.reporter.JUnitXmlPrinter.descriptions(JUnitXmlPrinter.scala:52)
    at org.specs2.reporter.JUnitXmlPrinter.descriptions$(JUnitXmlPrinter.scala:51)
    at org.specs2.reporter.JUnitXmlPrinter$.descriptions(JUnitXmlPrinter.scala:117)
    at org.specs2.reporter.JUnitXmlPrinter.$anonfun$saveResults$1(JUnitXmlPrinter.scala:35)
    at org.specs2.control.eff.EffImplicits$$anon$1.bind(Eff.scala:163)
    at org.specs2.control.eff.EffImplicits$$anon$1.bind(Eff.scala:141)
    at org.specs2.control.origami.Fold$$anon$2.end(Fold.scala:44)

Details:

  • Play Framework version: 2.8.19
  • scala version: 2.12.17
  • java version: 17
  • specs2-mock: 4.13.3
  • specs2-core: 4.13.3
  • scalacOptions:=Seq("-release", "17")

I have also tried upgrading specs2 version from 4.13.3 to 4.17.0 and then to 4.20.0 but didn't work.

My demo test case looks like this.

import org.specs2.mock.Mockito
import org.specs2.mutable.Specification


class DemoTest extends Specification with Mockito {

  isolated


  "DemoTest.calculate" should {

    """ return 5""" in {

      val demo = new Demo()

      demo.run() shouldEqual 5
    }

  }

}

I have also taken care of the things required to run Play framework using java17.https://github.com/playframework/playframework/releases/2.8.15

What might be the possible cause for it?

I tried upgrading the specs2 version and I was expecting that with most recent play framework version, the updated version of specs2 should fix the issue but that didnt happen.

0

There are 0 answers