jackmiras
05/17/2017, 6:00 PMjk
05/17/2017, 6:02 PMopen class
?jackmiras
05/17/2017, 6:04 PMjackmiras
05/17/2017, 6:15 PMjk
05/17/2017, 6:16 PMjk
05/17/2017, 6:16 PMjackmiras
05/17/2017, 6:17 PMjk
05/17/2017, 6:25 PMjk
05/17/2017, 6:30 PMjackmiras
05/17/2017, 6:30 PMrequest
and response
objects and run the UserPresenterTest
with the following command gradle -Dtest.single=UserPresenterTest test
and I got a different error:
Failures (1):
Spek:user.UserPresenterTest:given the user presenter:given a post action with a already registered user
=> org.mockito.exceptions.misusing.UnfinishedVerificationException:
Missing method call for verify(mock) here:
-> at user.UserPresenter.render(UserPresenter.kt:105)
Example of correct verification:
verify(mock).doSomething()
Also, this error might show up because you verify either of: final/private/equals()/hashCode() methods.
Those methods *cannot* be stubbed/verified.
Mocking methods declared on non-public parent classes is not supported.
jackmiras
05/17/2017, 6:31 PMobject UserPresenterTest : Spek({
given("the user presenter") {
val request = mock<Request>()
val response = mock<Response>()
given("a post action with a valid user to register") {
afterGroup { userFactory.clear() }
on("the attempt to register a valid user") {
it("should have a positive match for valid user from json") {
val user = userFactory.build()
doReturn(user.toJson()).whenever(request).body()
<http://userPresenter.post|userPresenter.post>(request, response)
userPresenter.user.isValid().shouldBeTrue()
}
}
}
}
})
open class UserPresenter : UserContract {
override fun post(request: Request, response: Response): Answer {
user = request.bodyAsObject(User::class)
if (userRepository.isAlreadyPersisted(user.email)) {
return render(response, getMessage(request.locale(), "user_already_exists"), 409)
} else if (user.isValid()) {
user.logged = true
userRepository.save(user)
return render(response, user, 201)
} else {
return render(response, getMessage(request.locale(), "invalid_params"), 422)
}
}
fun render(response: Response, message: String, status: Int): Answer {
response.type("application/json")
response.status(status) // This is the line number 105 referenced at the exception.
return Answer(message, status)
}
}
jk
05/17/2017, 6:46 PMjackmiras
05/17/2017, 6:56 PMrobfletcher
05/18/2017, 11:21 PMsubject
that has dependencies using SubjectSpek
?raniejade
05/21/2017, 12:22 PM'
from can't find previous dvir
?artemiy
05/21/2017, 11:50 PMjackmiras
05/22/2017, 3:56 PMgradle junitPlatformTest
commandartemiy
05/22/2017, 3:59 PMgradle test
but it runs the same thing), but it's just not looking very prettyartemiy
05/22/2017, 4:01 PMrook
05/22/2017, 4:49 PM'
, but it’s still acting up. I made a new separate project that is very basic to reproduce it. You can find the repo here: https://github.com/nukeforum/lunch-learnrook
05/22/2017, 6:47 PMon{}
doesn’t return a group. It looks like it’s not meant to be used to nest groups of tests. Is this correct?raniejade
05/23/2017, 12:54 AMon
as a special kind of test
, it represents a certain action. The its
will normally contain your assertions.jackmiras
05/23/2017, 3:17 PM=> java.lang.AssertionError: Expected class user.User to be an instance of class user.User
?artemiy
05/23/2017, 3:24 PMjackmiras
05/23/2017, 3:31 PMit("should KClass not be KClass<Any> instance") {
repositoryMocked.findBy("_id", user.id, User::class)
argumentCaptor<KClass<Any>>().apply {
verify(repositoryMocked, atLeastOnce()).findBy(eq("_id"), eq(user.id), capture())
thirdValue shouldBeInstanceOf User::class
}
}
hhariri
jasper
05/25/2017, 5:15 AMdependencies {
compile("org.springframework.boot:spring-boot-starter")
compile("org.hibernate:hibernate-validator")
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile 'org.jetbrains.spek:spek-api:1.1.2'
testRuntime 'org.jetbrains.spek:spek-junit-platform-engine:1.1.2'
}
jasper
05/25/2017, 5:16 AM@RunWith(JUnitPlatform::class)
<---- Unresolved 'JUnitPlatform::class'jasper
05/25/2017, 5:16 AMraniejade
05/25/2017, 5:17 AMorg.junit.platform:junit-platform-runner