Skip to content

Instantly share code, notes, and snippets.

@stoichoandreev
Last active May 11, 2021 08:59
Show Gist options
  • Save stoichoandreev/b14319197a90129a71e90eacfe0b1020 to your computer and use it in GitHub Desktop.
Save stoichoandreev/b14319197a90129a71e90eacfe0b1020 to your computer and use it in GitHub Desktop.
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
*/
fun <T: BaseRobot>RUN_UNIT_TEST(
robot: T,
block: TestRun<T>.() -> Unit
) : TestRun<T> {
val startTime = System.nanoTime()
println("*** UNIT TEST start ***")
val testRun = TestRun(robot, true)
block(testRun)
val difference = System.nanoTime() - startTime
println("*** time -> ${ TimeUnit.NANOSECONDS.toMillis(difference) } ms ***")
println("-----------------------------------------------------------------------------------------------")
return testRun
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment