InstrumentedReportRule

A test rule that builds a detailed report for a test, including its steps.

You can also extend this class to provide a default report configuration across all tests:

class SampleReportRule : InstrumentedReportRule(
reporter = CariocaAllureReporter(),
recordingOptions = RecordingOptions(
bitrate = 20_000_000,
resolutionScale = 1.0f,
),
screenshotOptions = ScreenshotOptions(
scale = 1f
),
interceptors = listOf(LoggerInterceptor(), DumpHierarchyInterceptor())
)
@get:Rule
val report = SampleReportRule()

@Test
fun sampleTest() = report {
step("Open notification and quick settings") {
step("Open notification") {
device.openNotification()
screenshot("Notification bar visible")
}
step("Open quick settings") {
device.openQuickSettings()
screenshot("Quick settings displayed")
}
}
step("Press home") {
device.pressHome()
}
}

Parameters

reporter

the instrumented reporter for this report

recordingOptions

the default recording options for this report

screenshotOptions

the default screenshot options for this report

interceptors

the interceptors that will receive multiple stage events during the lifecycle of this report

Constructors

Link copied to clipboard
constructor(reporter: InstrumentedReporter = DefaultInstrumentedReporter(), recordingOptions: RecordingOptions = RecordingOptions(), screenshotOptions: ScreenshotOptions = ScreenshotOptions(), interceptors: List<CariocaInstrumentedInterceptor> = listOf( LoggerInterceptor(), TakeScreenshotOnFailureInterceptor(), DumpViewHierarchyInterceptor(), ))

Public constructor that uses TestStorageProvider to save the reports

Functions

Link copied to clipboard
fun after(title: String = "After", block: InstrumentedStageScope.() -> Unit)

Use this to track @After methods separately from the other stages

Link copied to clipboard
open override fun apply(p0: Statement, p1: Description): Statement
Link copied to clipboard
fun before(title: String = "Before", block: InstrumentedStageScope.() -> Unit)

Use this to track @Before methods separately from the other stages

Link copied to clipboard
operator fun invoke(block: InstrumentedTestScope.() -> Unit)

Same as test, but without the extra method call

Link copied to clipboard
fun test(block: InstrumentedTestScope.() -> Unit)

Use this to start reporting the main test body