alexruiz / fest-assert-2.x

FEST Fluent Assertions 2.x
http://fest.easytesting.org
Apache License 2.0
402 stars 69 forks source link

Add StringAssert.containsSequence #147

Open bric3 opened 11 years ago

bric3 commented 11 years ago

In the same idea as issue 120 https://github.com/alexruiz/fest-assert-2.x/issues/120

It would nice to be able to test that different portions of a string appears in order (whatever is between them). So at each eaten verified "subsequence", the assertion will verify only to the rest of the non verified String. It could be useful to verify a portion of an XML node for example.

joel-costigliola commented 11 years ago

If I understand you correctly the assertion below would succeed ...

String book = "{ 'title':'A Game of Thrones', 'author':'George Martin'}";
assertThat(book).containsSequence("{", "title", "A Game of Thrones", "}");

... while this one would fail as "author" comes after "A Game of Thrones" :

assertThat(book).containsSequence("{", "author", "A Game of Thrones", "}");

I think this can be a nice addition to String assertions, thanks for the idea.

bric3 commented 11 years ago

Precisely what I meant :)

Hackergarteny idea I think ;)

joel-costigliola commented 11 years ago

For your information, this issue has been fixed in AssertJ a fork of Fest Assert 2.0M10.