Search in sources :

Example 6 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project scylla by bptlab.

the class TestUtils method getAttribute.

public static Object getAttribute(Object o, String attributeName) {
    try {
        Field field = getFieldNamed(o.getClass(), attributeName);
        field.setAccessible(true);
        return field.get(o);
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
        throw new AssertionFailedError("Attribute " + attributeName + " in class named " + o.getClass().getSimpleName() + " was not found.");
    }
}
Also used : Field(java.lang.reflect.Field) AssertionFailedError(org.opentest4j.AssertionFailedError)

Example 7 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project scylla by bptlab.

the class TestUtils method assertAttribute.

public static void assertAttribute(Object o, String attributeName, Object expectedValue) {
    try {
        Object actualValue = getAttribute(o, attributeName);
        assertEquals(expectedValue, actualValue);
    } catch (SecurityException | IllegalArgumentException e) {
        throw new AssertionFailedError("Could not validate attribute " + attributeName + " in class named " + o.getClass().getSimpleName() + ": Not existent or not accessible!", e);
    }
}
Also used : AssertionFailedError(org.opentest4j.AssertionFailedError)

Example 8 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project junit5 by junit-team.

the class AssertTimeoutAssertionsTests method assertTimeoutPreemptivelyForExecutableThatCompletesAfterTheTimeout.

@Test
void assertTimeoutPreemptivelyForExecutableThatCompletesAfterTheTimeout() {
    AssertionFailedError error = assertThrows(AssertionFailedError.class, () -> assertTimeoutPreemptively(PREEMPTIVE_TIMEOUT, this::waitForInterrupt));
    assertMessageEquals(error, "execution timed out after " + PREEMPTIVE_TIMEOUT.toMillis() + " ms");
    assertMessageStartsWith(error.getCause(), "Execution timed out in ");
    assertStackTraceContains(error.getCause().getStackTrace(), "CountDownLatch", "await");
}
Also used : AssertionFailedError(org.opentest4j.AssertionFailedError)

Example 9 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project junit5 by junit-team.

the class AssertTimeoutAssertionsTests method assertTimeoutPreemptivelyWithMessageSupplierForSupplierThatCompletesAfterTheTimeout.

@Test
void assertTimeoutPreemptivelyWithMessageSupplierForSupplierThatCompletesAfterTheTimeout() {
    AssertionFailedError error = assertThrows(AssertionFailedError.class, () -> {
        assertTimeoutPreemptively(PREEMPTIVE_TIMEOUT, () -> {
            waitForInterrupt();
            return "Tempus Fugit";
        }, () -> "Tempus" + " " + "Fugit");
    });
    assertMessageEquals(error, "Tempus Fugit ==> execution timed out after " + PREEMPTIVE_TIMEOUT.toMillis() + " ms");
    assertMessageStartsWith(error.getCause(), "Execution timed out in ");
    assertStackTraceContains(error.getCause().getStackTrace(), "CountDownLatch", "await");
}
Also used : AssertionFailedError(org.opentest4j.AssertionFailedError)

Example 10 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project junit5 by junit-team.

the class AssertTimeoutAssertionsTests method assertTimeoutForSupplierThatCompletesAfterTheTimeout.

@Test
void assertTimeoutForSupplierThatCompletesAfterTheTimeout() {
    AssertionFailedError error = assertThrows(AssertionFailedError.class, () -> {
        assertTimeout(ofMillis(10), () -> {
            nap();
            return "Tempus Fugit";
        });
    });
    assertMessageStartsWith(error, "execution exceeded timeout of 10 ms by");
}
Also used : AssertionFailedError(org.opentest4j.AssertionFailedError)

Aggregations

AssertionFailedError (org.opentest4j.AssertionFailedError)142 Test (org.junit.jupiter.api.Test)67 AssertionTestUtils.expectAssertionFailedError (org.junit.jupiter.api.AssertionTestUtils.expectAssertionFailedError)12 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)8 IOException (java.io.IOException)8 URI (java.net.URI)8 WithMockUser (org.springframework.security.test.context.support.WithMockUser)8 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)8 Collectors (java.util.stream.Collectors)5 ThrowingCallable (org.assertj.core.api.ThrowableAssert.ThrowingCallable)4 GeneCentricEntry (org.uniprot.core.genecentric.GeneCentricEntry)4 GeneCentricDocument (org.uniprot.store.search.document.genecentric.GeneCentricDocument)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 SettingsProxyModel (com.synopsys.integration.alert.common.rest.model.SettingsProxyModel)3 Search (io.zulia.client.command.builder.Search)3 SearchResult (io.zulia.client.result.SearchResult)3 Assertions (org.junit.jupiter.api.Assertions)3 Order (org.junit.jupiter.api.Order)3 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)3 MultipleFailuresError (org.opentest4j.MultipleFailuresError)3