Making a test for a sealed trait in scala
I have a sealed trait that I want to write tests for. However, it is not possible to create an object of this sealed trait in the testing class. How can you test in this case.
Myclass.scala
sealed trait BaseTrait{
def myFunct = //an implemented function
}
case class SecondClass extends BaseTrait {
// This class I can test
// ...
}
MyclassTest.Scala
class MyclassTest extends WordSpec with MustMatchers{
//Here I want to write a test case for the function within the sealed trait
}
I am working on a project with Play Framework 2.3.6 and Scala and using ScalaTestPlus for testing.
+3
igalbenardete
source
to share
1 answer
This may not be possible. Your best bet is to instantiate a simpler class that extends and validates this trait.
0
Jagat
source
to share