artem_zin
07/04/2016, 8:41 AMTest : Spek({
on(“file created”) {
beforeEach { createTempFile() } // Instead of JUnit rule.
it(“should do something with file”) {
// some assertion
}
}
})
dmitriy.m
07/04/2016, 8:41 AMartem_zin
07/04/2016, 8:42 AMdmitriy.m
07/04/2016, 8:43 AMdmitriy.m
07/04/2016, 8:48 AMval folder
in the class body i haven’t access to this variable inside the closuredmitriy.m
07/04/2016, 8:48 AMbeforeEach
blockartem_zin
07/04/2016, 8:49 AMbeforeEach
dmitriy.m
07/04/2016, 8:50 AMdebug
07/04/2016, 10:49 AMdmitriy.m
07/04/2016, 1:29 PMit
, i.e.
context(“bla bla) {
on() {
it()
it()
}
on() {
it()
it()
}
}
and for the whole context
i need to execute some assert after each it
artem_zin
07/04/2016, 1:45 PMafterEach
(but it will be invoked for nested tests toodmitriy.m
07/04/2016, 2:09 PMdmitriy.m
07/04/2016, 2:09 PMdmitriy.m
07/04/2016, 2:09 PM….
afterEach {
it() {
}
}
dmitriy.m
07/04/2016, 2:10 PMit
?artem_zin
07/04/2016, 2:10 PMit
to afterEach
dmitriy.m
07/04/2016, 2:10 PMartem_zin
07/04/2016, 2:12 PMdescribe(“what’s going on”) {
afterEach {
doWhatYouNeedToDo()
}
it(“1”) {
}
it(“2”) {
}
}
artem_zin
07/04/2016, 2:13 PMafterEach
^ will be invoked after each it()
(same for nested its)dmitriy.m
07/04/2016, 2:14 PMafterEach
, will it be included in result report?igor.korotenko
07/04/2016, 2:16 PMit
blockdmitriy.m
07/04/2016, 2:16 PMdmitriy.m
07/04/2016, 2:17 PMraniejade
07/04/2016, 2:18 PMbeforeEach
and afterEach
are used for setting and cleaning up the spec, not a place to put assertionsraniejade
07/04/2016, 2:19 PMdmitriy.m
07/04/2016, 2:24 PMcontext(“item creation) {
on(“create item simple”) {
it(“test for creation item”) {
}
it("should add created item into result list") {
assertBucketWasAddedInList(testListSubscriber)
}
}
on(“create item from …”) {
//almost the same as first one
….
it("should add created item into result list") {
assertBucketWasAddedInList(testListSubscriber)
}
}
on(“create item from…”) {
///
….
it("should add created item into result list") {
assertBucketWasAddedInList(testListSubscriber)
}
}
}
dmitriy.m
07/04/2016, 2:27 PMraniejade
07/04/2016, 2:34 PMraniejade
07/04/2016, 2:36 PMval assertBucketWasAddedInList = { s: Something -> assert(....) }
dmitriy.m
07/04/2016, 2:42 PMinvoke