Skip to content

Commit

Permalink
TECH: Mark failed allure screenshot assertions as FAILED instead of B…
Browse files Browse the repository at this point in the history
…ROKEN
  • Loading branch information
Nikitae57 committed Nov 5, 2024
1 parent c62ce39 commit a596495
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import com.kaspersky.kaspresso.testcases.models.info.TestInfo
class VisualTestLateFailInterceptor : TestRunWatcherInterceptor {
override fun onAfterSectionStarted(testInfo: TestInfo) {
if (AllureVisualTestFlag.shouldFailLate.get()) {
throw ScreenshotsImpl.ScreenshotDoesntMatchException("There were failed screenshot comparisons. Check the allure report")
// Wrap with assertion error so test would be marked as FAILED instead of BROKEN
// See https://github.com/allure-framework/allure-kotlin allure-kotlin-commons/src/main/kotlin/io/qameta/allure/kotlin/util/ResultsUtils.kt
throw AssertionError(ScreenshotsImpl.ScreenshotDoesntMatchException("There were failed screenshot comparisons. Check the allure report"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ abstract class AllureVisualTestCase(
try {
device.screenshots.assert(tag, isFullWindow)
} catch (ex: ScreenshotsImpl.ScreenshotDoesntMatchException) {
if (failEarly) { throw ex }
if (failEarly) {
// Wrap with assertion error so test would be marked as FAILED instead of BROKEN
// See https://github.com/allure-framework/allure-kotlin allure-kotlin-commons/src/main/kotlin/io/qameta/allure/kotlin/util/ResultsUtils.kt
throw AssertionError(ex)
}

Allure.lifecycle.updateStep {
it.status = Status.FAILED
Expand Down

0 comments on commit a596495

Please sign in to comment.