jackmiras
08/02/2017, 3:00 PMgiven("a runSeedsAndConnect call") {
on("the attempt to create a datastore") {
val spy = spy(MongoDatabaseConnection())
it("should return a non null value") {
val datastore = mongoDatabaseConnection.runSeedsAndConnect()
datastore.shouldNotBeNull()
}
it("should return a Datastore instance") {
val datastore = mongoDatabaseConnection.runSeedsAndConnect()
datastore shouldBeInstanceOf Datastore::class
}
it("should call createDatastore function") {
spy.runSeedsAndConnect()
verify(spy, times(1)).createDatastore()
}
it("should call runSeeds function") {
val datastore = mongoDatabaseConnection.createDatastore()
spy.runSeedsAndConnect()
verify(spy, times(2)).runSeeds(datastore)
}
}
}
O problema acontece no teste it("should call runSeeds function") quando o verify(spy, times(2)).runSeeds(datastore) é envocado. Por algum motivo que eu desconheço eu não consigo fazer mais de uma chamada verify(...) quando eu estou utilizando um partial mock.