scalatest

What is the difference between should and must in scala testing? [duplicate]

五迷三道 提交于 2019-12-25 06:28:04
问题 This question already has an answer here : In ScalaTest is there any difference between `should`, `can`, `must` (1 answer) Closed 3 years ago . Both scalatest and Specs2 have separate matchers for should and must . However, I cannot find any explanation for why you would use one or the other. What exactly is the difference? 回答1: There is no difference, this is purely a syntactic preference. I personally prefer to use must in specs2 because I think that should can make people think that an

Scalatest, cannot call invokePrivate

别说谁变了你拦得住时间么 提交于 2019-12-25 03:26:15
问题 I wanted to test a private method in Scala, and found that Scalatest's PrivateMethodTester does what I need. But there seems to be an import problem. import org.scalatest._ //Alternatively, I tried //import org.scalatest.PrivateMethodTester //import org.scalatest.FlatSpec "calculateCutoffCriteria" should "give mu -2sigma, mu - sigma, mu + sigma, mu+2sigma as bounds" in { val testData = List(-1, -1, 0, 1, 1) val expected = (-2, -1, 1, 2) val thePrivateMethod = PrivateMethodTester.PrivateMethod

Is there a specific release of Mockito I should use with Playspec

我只是一个虾纸丫 提交于 2019-12-25 01:35:52
问题 Is there a specific release of Mockito I should use with Playspec ? I am observing a strange pattern. When I start IntelliJ and run unit tests, I get error org.mockito.internal.invocation.ArgumentsProcessor.expandArgs(Lorg/mockito/internal/invocation/MockitoMethod;[Ljava/lang/Object;)[Ljava/lang/Object; . Then I close IntelliJ and restart it. Then the tests run!. This is repeatable behavior. I am wondering if this could be due to some incompatible library which somehow gets resolved when

spark unit test framework examples OTHER THAN com.holdenkarau

ぐ巨炮叔叔 提交于 2019-12-24 23:02:35
问题 I am trying to write test case of spark scala application code. So I am planning to use SharedSparkSession for this purpose. I've seen other framework such as com.holdenkarau but I am looking for any other alternative especially using SharedSparkSeesion . So I tried finding sample examples using this SharedSparkSession from the web, but I am unable to do so. If you have any example, please post. 回答1: Spark own test framework can be used in Scala, SparkSession present there. Some dependencies

When testing Spray services with Scalatest, how to introduce implicit values?

只愿长相守 提交于 2019-12-24 15:21:48
问题 I have a service: trait MyService extends HttpService { def getDao(implicit dao: SomeDAO) = dao def someRoute = path("foo") { get { complete(getDao getSomething) } } } Then, I have an actor: class MyActor extends MyService with Actor { override def receive: Receive = runRoute(someRoute) def actorRefFactory: ActorRefFactory = context } My test class looks like this: class MyServiceTest extends FlatSpec with ScalatestRouteTest with MyService with Matchers with MockFactory { override implicit

java.lang.NoSuchMethodException in scalatest

自古美人都是妖i 提交于 2019-12-24 12:18:28
问题 I have such test class: package com.my.spark.test import org.apache.spark.SparkContext import org.scalatest.{ConfigMap, BeforeAndAfterAll, FunSuite} class MyTrainingSuiteIT extends FunSuite with BeforeAndAfterAll { private[this] var _sc: SparkContext = null private[this] val defaultCoresNumber = 1 private[this] val defaultMaster = s"local[$defaultCoresNumber]" private[this] val defaultName = "some-spark-integration-test" override def beforeAll(configMap: ConfigMap): Unit = { super.beforeAll()

ReactiveMongo ConnectionNotInitialized In Test After Migrating to Play 2.5

倖福魔咒の 提交于 2019-12-24 05:44:23
问题 After migrating my Play (Scala) app to 2.5.3, some tests of my code using ReactiveMongo that once passed now fail in the setup. Here is my code using ScalaTest: def fixture(testMethod: (...) => Any) { implicit val injector = new ScaldiApplicationBuilder() .prependModule(new ReactiveMongoModule) .prependModule(new TestModule) .buildInj() def reactiveMongoApi = inject[ReactiveMongoApi] def collection: BSONCollection = reactiveMongoApi.db.collection[BSONCollection](testCollection) lazy val id =

Avoid Inheriting Super Class Tests in ScalaTest

狂风中的少年 提交于 2019-12-24 05:27:28
问题 I'd like to use test code from another project which has tightly coupled some utility methods along with their tests. I would like to inherit from this class so I'm able to use the utility methods but don't want the accompanying tests. Is there a way to inherit from this other Suite without also registering the tests? I've tried extending from a replica of the class labeled with the @DoNotDiscover annotation but this doesn't seem to have the desired effect. I'd also be interested if there was

Scalamock: How to get “expects” for Proxy mocks?

ぐ巨炮叔叔 提交于 2019-12-23 12:26:55
问题 I am using Scalamock with ScalaTest, and am trying to mock a Java interface. I currently have: private val _iface = mock [MyInterface] now I want to do _iface expects `someMethod returning "foo" once But the compiler does not find expects . I imported org.scalatest._ and org.scalamock.scalatest._ . What else am I missing? 回答1: First of all, proxy mocks are not supported very well in ScalaMock 3, and I think they will be completely removed in ScalaMock 4. Do you really need to use proxy mocks

unresolved dependency: com.artima.supersafe#supersafe_2.12.4;1.1.3: not found

北城余情 提交于 2019-12-23 11:55:10
问题 I am trying to use scala test and write: resolvers += "Artima Maven Repository" at "http://repo.artima.com/releases" addSbtPlugin("com.artima.supersafe" % "sbtplugin" % "1.1.3") into plugins.sbt and build.sbt looks as following: libraryDependencies ++= Seq( "org.scalactic" %% "scalactic" % ScalaTest, "org.scalatest" %% "scalatest" % ScalaTest % "test" ) SBT complains: Error:Error while importing SBT project:<br/>...<br/><pre>[error] at sbt.internal.LibraryManagement$.cachedUpdate