我尝试在我的应用程序中使用 Scalamock 进行模拟,但我想要模拟的是一个带有参数的类。我看到了 scalamock 文档,他们说要模拟类,我必须导入org.scalamock.annotation.mock才能使用某些函数。我的参考是 scalatest docs。
“注释”似乎不存在......
我的 sbt 依赖项:
"org.scalamock" % "scalamock-scalatest-support_2.10" % "3.0.1" % "test"
"org.scalamock" % "scalamock-core_2.10" % "3.0.1"
Run Code Online (Sandbox Code Playgroud)
我想我忘记了一个图书馆,但我不知道它是什么..
编辑 :
测试代码:
import org.scalatest.FlatSpec
import org.scalamock.scalatest.MockFactory
class AuthenticationServiceTest extends FlatSpec with MockFactory
{
"A user" should " be authenticated" in
{
val user = mock[User]
val tenant = mock[Tenant]
inSequence {
(authenticate(tenant, user) _).expects.returning(true)
}
assert(authenticate(tenant, user))
}
}
Run Code Online (Sandbox Code Playgroud)
班级:
class User (
val username : String,
var password : String, …Run Code Online (Sandbox Code Playgroud) 从昨天开始,我尝试在Windows(Bootcamp MacBook Pro)上启动docker项目,而我只剩下一个问题:PostgreSQL映像。
错误信息 :
postgres_1 | The files belonging to this database system will be owned by user "postgres".
postgres_1 | This user must also own the server process.
postgres_1 |
postgres_1 | The database cluster will be initialized with locale "en_US.utf8".
postgres_1 | The default database encoding has accordingly been set to "UTF8".
postgres_1 | The default text search configuration will be set to "english".
postgres_1 |
postgres_1 | Data page checksums are disabled.
postgres_1 |
postgres_1 | …Run Code Online (Sandbox Code Playgroud) 我有一个Play Framework 2网站,它运行得很完美,但玩网站的方式并不能让我满意.让我解释一下:例如,我有一条用户注销的路由,所以我重定向到我的索引页面,但在网址中我仍然有"localhost:9000/logout ",对我来说它不是很明确,我更喜欢简单的"localhost:9000 /"或"localhost:9000/index"; 我有类似的情况,我想知道是否可以改变它,就像网址重写一样.
我没有在互联网上找到任何有用的主题,所以我希望你可以为我找到解决方案!