Skip to content

Instantly share code, notes, and snippets.

View Petrulak's full-sized avatar

Martin Petrulak Petrulak

View GitHub Profile
object RegistrationTest : Spek({
group("registration") {
beforeGroup { println("beforeGroup : registration") }
beforeEachTest { println("beforeEachTest : root") }
test("should initialize with default values") { println("test1") }
group("success") {
beforeEachTest { println("beforeEachTest : success") }
object RegistrationTest : Spek({
group("registration") {
beforeGroup { println("beforeGroup : registration") }
test("should initialize with default values") { println("test1") }
group("success") {
beforeEachTest { println("beforeEachTest : success") }
test("should proceed to next screen") { println("test2") }
object RegistrationTest : Spek({
group("registration") {
println("registration")
test("should initialize with default values") { println("test1") }
group("success") {
println("success")
test("should proceed to next screen") { println("test2") }
object BitCoinPriceRepositoryTest : Spek({
val pricesWrapperDtoMock = PricesWrapperDto.newMock()
val pricesMock = Prices.newMock()
val pricesMapper = PricesMapper()
val mappedValuesFromApi = pricesMapper.map(pricesWrapperDtoMock)
val refreshObserver by memoized { TestObserver.create<Void>() }
val remoteSource by memoized { mock(BitCoinRemoteSource::class.java) }
val mock by memoized(CachingMode.WE_CHANGE_THIS_ONE) { mock(Repository::class.java) }
beforeGroup { println("beforeGroup \t mock : $mock") }
beforeEachTest { println("beforeEachTest \t mock : $mock") }
group("A") {
test("test 1") { println("test 1 \t\t\t mock : $mock") }
}
group("B") {
/**
* Specifies how [lifecycle aware objects][MemoizedValue] are cached.
*/
enum class CachingMode {
/**
* Each group will get their own unique instance. Nested groups will have
* their own unique instance as well.
*/
GROUP,
val dynamicExclude = if (!BuildConfig.DEBUG) Skip.No else Skip.Yes("reason here")
describe("registration", skip = dynamicExclude) {
it("should stop refreshing") {}
}
describe("log in") {
it("should report logs", skip = dynamicExclude) {}
it("should stop refreshing") {}
enum class TRANSFORMER { FIRST, SECOND, THIRD, OTHER }
fun transform(input: Int) : TRANSFORMER {
return when (input) {
1 -> FIRST
2 -> SECOND
3 -> THIRD
else -> OTHER
}
describe("fetch user data") {
val repository by memoized { mock(Repository::class.java)}
val service by memoized { Service(repository)}
context("the data is fetched successfuly") {
lateinit var result : List<SomeData>
val expectedResult = listOf(...)
object HelloWorld : Spek({
val mock by memoized { mock(Repository::class.java) }
group("A") {
group("B") {
test("test 1") { println("mock : $mock")}
test("test 2") { println("mock : $mock")}