This file contains 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
dependencies { | |
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | |
implementation 'androidx.core:core-ktx:1.3.2' | |
implementation 'androidx.appcompat:appcompat:1.2.0' | |
implementation 'com.google.android.material:material:1.3.0' | |
testImplementation 'junit:junit:4.13.2' | |
testImplementation 'io.mockk:mockk:1.11.0' | |
testImplementation 'org.robolectric:robolectric:4.5.1' |
This file contains 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
@RunWith(AndroidJUnit4::class)//Be careful with the import here, do not import androidx.test.runner.AndroidJUnit4! You will need androidx.test.ext.junit.runners.AndroidJUnit4 | |
@Config(sdk = [24], application = MyTestApplication::class) | |
@LooperMode(LooperMode.Mode.PAUSED) | |
class LoginActivityTest { | |
private val robot = Robot() | |
@Before | |
fun setup() { | |
robot.setup() |
This file contains 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 com.sniper.bdd.robo.LoginPresenter | |
import com.sniper.bdd.robo.LoginValidator | |
import com.sniper.bdd.robo.data.DataFactory | |
import io.mockk.MockKAnnotations | |
import io.mockk.every | |
import io.mockk.impl.annotations.RelaxedMockK | |
import io.mockk.verify | |
import org.junit.Before | |
import org.junit.Test |
This file contains 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 com.sniper.bdd.robo.BaseRobot | |
import com.sniper.bdd.robo.LoginPresenter | |
import com.sniper.bdd.robo.LoginValidator | |
import com.sniper.bdd.robo.data.DataFactory | |
import com.sniper.bdd.robo.dsl.GIVEN | |
import com.sniper.bdd.robo.dsl.RUN_UNIT_TEST | |
import com.sniper.bdd.robo.dsl.THEN | |
import com.sniper.bdd.robo.dsl.WHEN | |
import io.mockk.MockKAnnotations | |
import io.mockk.every |
This file contains 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
/** | |
* Each test Robot in our application (UI test Robot or Unit test Robot) should extend BaseRobot | |
*/ | |
open class BaseRobot { | |
/** | |
* Use the method to setup stuff in your Robot class before each test run | |
*/ | |
open fun setup() { | |
//no base implementation | |
} |
This file contains 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 com.sniper.bdd.robo.BaseRobot | |
import java.util.concurrent.TimeUnit | |
/** | |
* Use the method to run single UI test | |
* @param robot - Set your test robot (should extend BaseRobot) | |
* @param block - the block of code which needs to be executed in our test. Usually we need to place inside all steps for the test | |
* @return - TestRun data class instance, which includes the test name and the robot instance |
This file contains 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 com.sniper.bdd.robo.BaseRobot | |
import java.util.concurrent.TimeUnit | |
/** | |
* Use the method to run single unit test | |
* @param robot - Set your test robot (should extend BaseRobot) | |
* @param block - the block of code which needs to be executed in our test. Usually we need to place inside all steps for the test | |
* @return - TestRun data class instance, which includes the test name and the robot instance |
This file contains 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 com.sniper.bdd.robo.BaseRobot | |
/** | |
* Use the method to setup GIVEN step for any test (Unit and Instrumentation) | |
* @param block - the block of code which needs to be executed in the GIVEN step | |
* @return - robot instance of the test robot, it allows us to call robot methods directly | |
*/ | |
fun <T: BaseRobot>TestRun<T>.GIVEN( | |
block: T.() -> Unit |
This file contains 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
data class Ad(val id: String) |
This file contains 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
object DataApiService { | |
fun loadData(): Observable<DataModel> { | |
return Observable.just(DataModel("data_model")) | |
} | |
fun loadAnoteherData(): Observable<AnotherDataModel> { | |
return Observable.just(AnotherDataModel("another_data_model")) | |
} | |
} |
NewerOlder