[shrinkwrap-issues] [JBoss JIRA] (SHRINKDESC-89) Improve test code readability by introducing assertion DSL

Michal Matloka (JIRA) jira-events at lists.jboss.org
Wed Nov 28 01:56:21 EST 2012


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

Michal Matloka commented on SHRINKDESC-89:
------------------------------------------

They are currently both in central for sure, even fest core assertions 2.0 milestone versions.  Hamcrest is currently in some JUnit builds but FEST is much easier to use in practice - better IDE support (code completition) when you create simply fluent chain of assertions - Hamcrest assertThat(sth, isSth()) vs FEST assertThat(sth).isSth(). IDE tells you what you can do with supplied objects. If this hasn't been introduced yet, I would vote for FEST ;)
                
> Improve test code readability by introducing assertion DSL
> ----------------------------------------------------------
>
>                 Key: SHRINKDESC-89
>                 URL: https://issues.jboss.org/browse/SHRINKDESC-89
>             Project: ShrinkWrap Descriptors
>          Issue Type: Task
>          Components: test
>    Affects Versions: 1.1.0-alpha-5
>            Reporter: Bartosz Majsak
>            Assignee: Bartosz Majsak
>            Priority: Optional
>              Labels: testing
>
> Improving tests assertion might bring few benefits for us, such as:
> * more concise tests focused on the functionality
> * better readability and understanding of the tests (and the way how our tool works in general [which might be really handy for newcomers]), also by using domain-specific assertions
> * easier maintenance
> For instance for Node assertions we could have:
> {code}
> assertThat(root.getChildren()).containsOnly(CHILD_1, CHILD_2)
> {code}
> or even something more fancy
> {code}
> assertThat(node).isAccessibleFrom(otherNode)
> {code}
> Two options worth considering are:
> * [Hamcrest|http://code.google.com/p/hamcrest/] (bundled with JUnit as of 4.4)
> * [FEST-Assert|http://docs.codehaus.org/display/FEST/Fluent+Assertions+Module]
> I would rather go with the latter. Its' fluent interface DSL is somehow easier to use in tests.
> When it comes to dependencies, here's the full list:
> {code}
> org.easytesting:fest-assert:jar:1.3 
>     org.easytesting:fest-util:jar:1.1.4 (compile) 
>     org.easytesting:fest-reflect:jar:1.2 (test) 
>     org.easytesting:fest-test:jar:1.2.1 (test) 
>         junit:junit:jar:4.7 (test) 
>     org.easytesting:fest-mocks:jar:1.1.1 (test) 
>         org.easymock:easymockclassextension:jar:2.4 (test) 
>             org.easymock:easymock:jar:2.4 (test) 
>             cglib:cglib-nodep:jar:2.1_3 (test) 
>         org.easymock:easymock:jar:2.4 (test) 
>     junit:junit:jar:4.7 (test) 
> {code}

--
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 shrinkwrap-issues mailing list