This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.reactivex.subjects.BehaviorSubject | |
class ObservableProperty<T>(private val defaultValue: T) { | |
var value: T = defaultValue | |
set(value) { | |
field = value | |
observable.onNext(value) | |
} | |
val observable = BehaviorSubject.createDefault(value) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Calculator | |
As a user | |
I want to use a calculator to add numbers | |
So that I don't need to add myself | |
Scenario: Add two numbers -2 & 3 | |
Given I have a calculator | |
When I add -2 and 3 | |
Then the result should be 1 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testImplementation 'io.kotlintest:kotlintest-runner-junit5:3.3.2' | |
testImplementation 'io.mockk:mockk:1.9.3.kotlin12' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GradeCalculatorSpec : BehaviorSpec({ | |
Given("a grade calculator") { | |
val calculator = spyk(GradeCalculator()) | |
every { calculator.totalMarks } returns 100 | |
val total = calculator.totalMarks | |
When("obtained marks are 90 or above") { | |
Then("grade is A") {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GradeCalculator { | |
var totalMarks = 0 | |
fun getGrade(obtainedMarks: Int, totalMarks: Int): String { | |
val percentage = getPercentage(obtainedMarks, totalMarks) | |
return when { | |
percentage >= 90 -> "A" | |
percentage in 80..89 -> "B" | |
percentage in 70..79 -> "C" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.zuhaibahmad.bddtestingtutorial | |
import io.kotlintest.shouldBe | |
import io.kotlintest.specs.BehaviorSpec | |
import io.mockk.every | |
import io.mockk.spyk | |
class GradeCalculatorSpec : BehaviorSpec({ | |
Given("a grade calculator") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When("user list is fetched from API") { | |
And("the internet is NOT available"){ | |
Then("Test something"){ | |
// Some assertions | |
} | |
} | |
And("the internet is available"){ | |
Then("Test something"){ | |
// Some assertions | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.lang.reflect.Method; | |
import android.content.Context; | |
import dalvik.system.DexFile; | |
public class SystemPropertiesProxy | |
{ | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -L http://bit.ly/10hA8iC | bash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FormScreen : Screen<FormScreen>() { | |
val phone = KView { withId(R.id.phone) } | |
val email = KEditText { withId(R.id.email) } | |
val submit = KButton { withId(R.id.submit) } | |
} |