Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE-638: Added ability to disable screenshots in allure integration #674

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.kaspersky.kaspresso.files.resources.impl.DefaultResourceFilesProvider
import com.kaspersky.kaspresso.files.resources.impl.DefaultResourcesDirNameProvider
import com.kaspersky.kaspresso.files.resources.impl.DefaultResourcesDirsProvider
import com.kaspersky.kaspresso.instrumental.InstrumentalDependencyProvider
import com.kaspersky.kaspresso.interceptors.watcher.testcase.StepWatcherInterceptor
import com.kaspersky.kaspresso.kaspresso.Kaspresso
import com.kaspersky.kaspresso.runner.listener.addUniqueListener
import com.kaspersky.kaspresso.runner.listener.getUniqueListener
Expand Down Expand Up @@ -74,7 +75,23 @@ fun Kaspresso.Builder.Companion.withForcedAllureSupport(
forceAllureSupportFileProviders(instrumentalDependencyProvider)
addRunListenersIfNeeded(instrumentalDependencyProvider)
}.apply {
postInitAllure(shouldRecordVideo, builder = this)
postInitAllure(shouldRecordVideo, true, builder = this)
}

fun Kaspresso.Builder.Companion.withForcedAllureSupport(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, remove the old builder. it bacame useless with your changes

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devapro kindly reminder

shouldRecordVideo: Boolean = true,
shouldCaptureScreenShots: Boolean = true,
customize: Kaspresso.Builder.() -> Unit = {}
): Kaspresso.Builder = simple {
if (!isAndroidRuntime) {
return@simple
}
customize.invoke(this)
val instrumentalDependencyProvider = instrumentalDependencyProviderFactory.getComponentProvider<Kaspresso>(instrumentation)
forceAllureSupportFileProviders(instrumentalDependencyProvider)
addRunListenersIfNeeded(instrumentalDependencyProvider)
}.apply {
postInitAllure(shouldRecordVideo, shouldCaptureScreenShots, builder = this)
}

private fun Kaspresso.Builder.forceAllureSupportFileProviders(provider: InstrumentalDependencyProvider) {
Expand Down Expand Up @@ -111,22 +128,28 @@ private fun Kaspresso.Builder.addRunListenersIfNeeded(provider: InstrumentalDepe
}
}

private fun postInitAllure(shouldRecordVideo: Boolean, builder: Kaspresso.Builder): Unit = with(builder) {
private fun postInitAllure(shouldRecordVideo: Boolean, shouldCaptureScreenShots: Boolean, builder: Kaspresso.Builder): Unit = with(builder) {
if (!isAndroidRuntime) {
return@with
}
stepWatcherInterceptors.addAll(
listOf(
ScreenshotStepInterceptor(screenshots),
mutableListOf<StepWatcherInterceptor>(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, use buildList function to preserve the current interceptors order

AllureMapperStepInterceptor()
)
).apply {
if (shouldCaptureScreenShots) {
add(ScreenshotStepInterceptor(screenshots))
}
}
)
testRunWatcherInterceptors.addAll(
listOf(
mutableListOf(
DumpLogcatTestInterceptor(logcatDumper),
ScreenshotTestInterceptor(screenshots),
DumpViewsTestInterceptor(viewHierarchyDumper),
)
).apply {
if (shouldCaptureScreenShots) {
add(ScreenshotTestInterceptor(screenshots))
}
}
)
if (shouldRecordVideo) {
val provider = instrumentalDependencyProviderFactory.getComponentProvider<Kaspresso>(instrumentation)
Expand Down