Skip to content

Commit

Permalink
Fix assertion error exception (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-tiurin authored Mar 17, 2024
1 parent d37e965 commit a108073
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ kotlin.code.style=official
android.useAndroidX=true
GROUP=com.atiurin
POM_ARTIFACT_ID=ultron
VERSION_NAME=2.3.4
VERSION_NAME=2.3.5

POM_NAME=ultron

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object AssertUtils {
Assert.assertTrue(System.currentTimeMillis() - startTime <= time)
}

fun assertExecTimeBetween(minTime: Long, maxTime: Long,block: () -> Unit){
fun assertExecTimeBetween(minTime: Long, maxTime: Long, block: () -> Unit) {
val startTime = System.currentTimeMillis()
try {
block()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ class RecyclerViewTest : BaseTest() {
}
}

@Test
fun item_notExist_executionTime() {
val timeout = 5_000L
AssertUtils.assertExecTimeMoreThen(timeout){
AssertUtils.assertException {
runCatching { page.recycler.withTimeout(timeout).item(withText("Not existed item")).isDisplayed() }
}
}
}

@Test
@SetUp(CUSTOM_TIMEOUT)
@TearDown(CUSTOM_TIMEOUT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ object UltronConfig {
UltronAssertionException::class.java,
PerformException::class.java,
NoMatchingViewException::class.java,
AmbiguousViewMatcherException::class.java
AmbiguousViewMatcherException::class.java,
UltronOperationException::class.java
)
val resultHandler: (EspressoOperationResult<UltronEspressoOperation>) -> Unit = {
resultAnalyzer.analyze(it)
Expand All @@ -158,10 +159,11 @@ object UltronConfig {
UltronWrapperException::class.java,
UltronException::class.java,
UltronAssertionException::class.java,
UltronOperationException::class.java,
PerformException::class.java,
NoMatchingViewException::class.java,
AssertionFailedError::class.java,
AmbiguousViewMatcherException::class.java
AmbiguousViewMatcherException::class.java,
)
val resultHandler: (EspressoOperationResult<UltronEspressoOperation>) -> Unit = {
resultAnalyzer.analyze(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.atiurin.ultron.exceptions

import android.annotation.SuppressLint

class UltronOperationException : AssertionError {
class UltronOperationException : RuntimeException {
constructor(message: String) : super(message)
@SuppressLint("NewApi")
constructor(message: String, cause: Throwable) : super(message, cause)
Expand Down

0 comments on commit a108073

Please sign in to comment.