scalatest

How to programmatically ignore/skip tests with ScalaTest?

 ̄綄美尐妖づ 提交于 2019-11-27 16:17:05
问题 I am running some tests with ScalaTest which rely on connections to test servers to be present. I currently created my own Spec similar to this: abstract class ServerDependingSpec extends FlatSpec with Matchers { def serverIsAvailable: Boolean = { // Check if the server is available } } Is it possible to ignore (but not fail) tests when this method returns false ? Currently I do it in a "hackish" way: "Something" should "do something" in { if(serverIsAvailable) { // my test code } } but I

Mockito matchers, scala value class and NullPointerException

ぃ、小莉子 提交于 2019-11-27 15:45:53
问题 I'm using mockito with scalatest. I have following problem when using matcher with value class. import org.scalatest.FlatSpec import org.scalatest.mock.MockitoSugar import org.mockito.BDDMockito._ import org.mockito.Matchers.any case class FirstId(val value: String) extends AnyVal case class SecondId(val value: String) extends AnyVal trait MockedClass { def someMethods(firstId: FirstId, secondId: SecondId): Int } class ValueClassSpec() extends FlatSpec with MockitoSugar { val mockedClass =

“Unknown artifact. Not resolved or indexed” error for scalatest

ε祈祈猫儿з 提交于 2019-11-27 13:27:39
I'm trying to modify the build.sbt file to add scalatest dependencies in IntelliJ IDEA. There's no error log in the console but I got a Unknown artifact. Not resolved or indexed. when I hovered my mouse over the underline. How do I solve this? Many thanks in advance! This is the line I used to add dependency: libraryDependencies += "org.scalatest" % "scalatest_2.11" % "3.0.1" % "test" And here is what my screen looks like: If you just added the dependency, it might not have been downloaded yet. Refresh/reimport the project to do so. If it has already been downloaded, press Alt+Enter in

Doing something before or after all Scalatest tests

Deadly 提交于 2019-11-27 11:24:51
I have a suite of scalatest tests that test different endpoints of a RESTful API. I really want them separated into different files for best organization. My problem is how to start something (an HTTP server in my case, but it doesn't matter what it is) before all the tests and shut it down after all the tests are done. I know about BeforeAndAfterAll, but that only accomplishes before/after inside one test file. I need something like that, but for all tests, for example: -- start http server before tests -- run all test suites -- shut down http server The intended way to do this is to use

Scalatest - how to test println

青春壹個敷衍的年華 提交于 2019-11-27 00:58:39
问题 Is there something in Scalatest that will allow me to test the output to the standard out via a println statement? So far I've mainly been using FunSuite with ShouldMatchers . e.g. how do we check the printed output of object Hi { def hello() { println("hello world") } } 回答1: The usual way to test print statements on the console is to structure your program a bit differently so that you can intercept those statements. You can for example introduce an Output trait: trait Output { def print(s:

Doing something before or after all Scalatest tests

主宰稳场 提交于 2019-11-26 17:59:51
问题 I have a suite of scalatest tests that test different endpoints of a RESTful API. I really want them separated into different files for best organization. My problem is how to start something (an HTTP server in my case, but it doesn't matter what it is) before all the tests and shut it down after all the tests are done. I know about BeforeAndAfterAll, but that only accomplishes before/after inside one test file. I need something like that, but for all tests, for example: -- start http server

“Unknown artifact. Not resolved or indexed” error for scalatest

让人想犯罪 __ 提交于 2019-11-26 17:42:10
问题 I'm trying to modify the build.sbt file to add scalatest dependencies in IntelliJ IDEA. There's no error log in the console but I got a Unknown artifact. Not resolved or indexed. when I hovered my mouse over the underline. How do I solve this? Many thanks in advance! This is the line I used to add dependency: libraryDependencies += "org.scalatest" % "scalatest_2.11" % "3.0.1" % "test" And here is what my screen looks like: 回答1: If you just added the dependency, it might not have been

Jvm takes a long time to resolve ip-address for localhost

北慕城南 提交于 2019-11-26 10:13:49
I seem to have a problem with performance of "sbt test" after upgrading to macOS Sierra. On a previous version of OS X it took about 40-50 seconds to finish. macOS Sierra times are much higher than that. Last run I did was around 15 minutes. Compile times are about the same as on 'El Capitan'. I'm the only one from my team to try this new macOS so I can't tell if it's only happening on my mac or is it a universal issue. My colleague had a similar issue on Ubuntu and it was related with random number generation slowing down the tests - Slow service response Times : Java SecureRandom & /dev

Jvm takes a long time to resolve ip-address for localhost

本小妞迷上赌 提交于 2019-11-26 02:06:02
问题 I seem to have a problem with performance of \"sbt test\" after upgrading to macOS Sierra. On a previous version of OS X it took about 40-50 seconds to finish. macOS Sierra times are much higher than that. Last run I did was around 15 minutes. Compile times are about the same as on \'El Capitan\'. I\'m the only one from my team to try this new macOS so I can\'t tell if it\'s only happening on my mac or is it a universal issue. My colleague had a similar issue on Ubuntu and it was related with