timurt · GitHub

Hi

I have the following assertions:

        String str = ...;
        assertWithMessage(errorMessage)
                .that(str)
                .startsWith("some prefix");
        assertWithMessage(errorMessage)
                .that(str)
                .contains("some content");
        assertWithMessage(errorMessage)
                .that(str)
                .endsWith("some suffix");

As you can see I make several assertions over one str object
It would be easier to understand if all assertions were combined together like:

        assertWithMessage(errorMessage)
                .that(str)
                .startsWith("some prefix")
                .contains("some content")
                .endsWith("some suffix");

I know there are several ways how to overcome it (assign assertWithMessage(errorMessage).that(str) to variable and call assertions for it or by using regular expressions), but sequential invocation of assert methods over one object seems more natural to me


Please guide me, if such functionality already exists

Read the original on github.com ↗