[richfaces-issues] [JBoss JIRA] (RF-13130) Add Hamcrest for BDD-style assertions

Lukáš Fryč (JIRA) jira-events at lists.jboss.org
Wed Aug 14 12:24:26 EDT 2013


    [ https://issues.jboss.org/browse/RF-13130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12796848#comment-12796848 ] 

Lukáš Fryč commented on RF-13130:
---------------------------------

Hamcrest-style API provides more readable tests, but more importantly results - compare:

{code}
Assert.assertTrue(list.isEmpty());
{code}

Fails with: {{AssertionError}}

{code}
Assert.assertTrue("list is empty", list.isEmpty());
{code}

Fails with: {{list is empty}}

{code}
Assert.assertThat(list, is(empty());
{code}

Fails with: {{The 'list' is expected to be empty, but it was: ...}}

----

The second option is refactoring proof, as it does not have to bear any message in order to understand what assertion has been made.

Both APIs are part of JUnit, since JUnit transitionally depends on Hamcrest Core, however in Hamcrest Core are just simple matchers, e.g. it misses:

{code}
Assert.assertThat(someString, containsString("foo"));
{code}
                
> Add Hamcrest for BDD-style assertions
> -------------------------------------
>
>                 Key: RF-13130
>                 URL: https://issues.jboss.org/browse/RF-13130
>             Project: RichFaces
>          Issue Type: Feature Request
>      Security Level: Public(Everyone can see) 
>          Components: tests - unit
>            Reporter: Lukáš Fryč
>            Assignee: Lukáš Fryč
>             Fix For: 5.0.0.Alpha2
>
>
> https://code.google.com/p/hamcrest/

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the richfaces-issues mailing list