Skip to content

assertThatThrownBy doesNotThrowAnyException fail when callable doesnt throw any exception #1787

@dattebayorob

Description

@dattebayorob

Summary

In my test the method call should pass if none exception is throwed, but if the ThrowingCallable doesn't throw anything an assertion error happens

Example

@Test
@DisplayName("Should Delete a person by CPF and then save another person with this cpf")
void shouldDeleteAPersonByCPFAndThenSaveAnotherPersonWithThisCPF() {		 
     assertThatThrownBy(() -> { service.batchOperationByCPF(CPF); }).doesNotThrowAnyException();
}

Am I doing something wrong?

java.lang.AssertionError: 
Expecting code to raise a throwable.
	at com.dtb.jpadeletetest.service.PersonServiceIT.shouldDeleteAPersonByCPFAndThenSaveAnotherPersonWithThisCPF(PersonServiceIT.java:38)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions