Created
April 28, 2021 12:23
-
-
Save stoichoandreev/2b816f9a337b5e5a5006b6d59c37e31b to your computer and use it in GitHub Desktop.
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 | |
): T { | |
//you can print something here | |
return robot.apply(block) | |
} | |
/** | |
* Use the method to setup WHEN step for any test (Unit and Instrumentation) | |
* @param block - the block of code which needs to be executed in the WHEN step | |
* @return - robot instance of the unit test, it allows us to call robot methods directly | |
*/ | |
fun <T: BaseRobot>TestRun<T>.WHEN( | |
block: T.() -> Unit | |
): T { | |
//you can print something here too | |
return robot.apply(block) | |
} | |
/** | |
* Use the method to setup AND step for any test (Unit and Instrumentation) | |
* @param block - the block of code which needs to be executed in the AND step | |
* @return - robot instance of the unit test, it allows us to call robot methods directly | |
*/ | |
fun <T: BaseRobot>TestRun<T>.AND( | |
block: T.() -> Unit | |
): T { | |
//you can print something here too | |
return robot.apply(block) | |
} | |
/** | |
* Use the method to setup THEN step for any test (Unit and Instrumentation) | |
* @param block - the block of code which needs to be executed in the THEN step | |
* @return - robot instance of the unit test, it allows us to call robot methods directly | |
*/ | |
fun <T: BaseRobot>TestRun<T>.THEN( | |
block: T.() -> Unit | |
): T { | |
//you can print something here too | |
return robot.apply(block) | |
} | |
/** | |
* Simple data class which represents the test it self. We can add as much properties we need | |
*/ | |
data class TestRun<T: BaseRobot>( | |
val robot: T, | |
val isUnitTest: Boolean | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment