jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
Signup
FEST
  • FEST
  • FEST-406

OR assertions

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: New Feature New Feature
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: FEST-Assert 1.3
  • Fix Version/s: FEST-Assert 2.0M1
  • Component/s: Assert
  • Labels:
    None
  • Number of attachments :
    0

Description

Based on http://groups.google.com/group/easytesting/browse_thread/thread/3e74becf8f6f1460?hl=en.
Something like:

assertThat(variable).isEqualTo(a).or().isEqualTo(b); 

or

assertThat(variable).is(or(isEqualTo(a), isEqualTo(b)); 

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Johannes Zillmann added a comment - 18/Nov/10 10:48 AM

Just some more thoughts...
The second, hamcrest like approach, looks a like a bit more flexible, because it would be easy to add handy things like

any(x1, x2,...)
 noneOf(x1, x2,...)

etc...
But it would loose then the specific asserts, correct ?

Maybe something like

assertThat(variable, and()).isEqualTo(a).isEqualTo(b));
assertThat(variable, or()).isEqualTo(a).isEqualTo(b));
assertThat(variable, anyOf()).isEqualTo(a).isEqualTo(b));

wouldn't be flexible to hell, but keep the ease of fest ?

Show
Johannes Zillmann added a comment - 18/Nov/10 10:48 AM Just some more thoughts... The second, hamcrest like approach, looks a like a bit more flexible, because it would be easy to add handy things like any(x1, x2,...) noneOf(x1, x2,...) etc... But it would loose then the specific asserts, correct ? Maybe something like assertThat(variable, and()).isEqualTo(a).isEqualTo(b)); assertThat(variable, or()).isEqualTo(a).isEqualTo(b)); assertThat(variable, anyOf()).isEqualTo(a).isEqualTo(b)); wouldn't be flexible to hell, but keep the ease of fest ?
Hide
Permalink
Joel Costigliola added a comment - 18/Nov/10 3:11 PM

isIn / isNotIn assertions should do the job.

assertThat(variable).isEqualTo(a).or().isEqualTo(b); 
// or any(a, b,...)

can be written with isIn assertion as

assertThat(variable).isIn(a, b);

besides

noneOf(x1, x2,...)

can be written with isNotIn assertion as

assertThat(variable).isNotIn(x1, x2, ...);

Note also that isIn/isNotIn supports collection parameters, one can write

Collection myCollection = ... ; // init a collection with a and b
assertThat(variable).isIn(myCollection); 
Show
Joel Costigliola added a comment - 18/Nov/10 3:11 PM isIn / isNotIn assertions should do the job. assertThat(variable).isEqualTo(a).or().isEqualTo(b); // or any(a, b,...) can be written with isIn assertion as assertThat(variable).isIn(a, b); besides noneOf(x1, x2,...) can be written with isNotIn assertion as assertThat(variable).isNotIn(x1, x2, ...); Note also that isIn/isNotIn supports collection parameters, one can write Collection myCollection = ... ; // init a collection with a and b assertThat(variable).isIn(myCollection);
Hide
Permalink
Johannes Zillmann added a comment - 19/Nov/10 3:02 AM

Hi Joel,

thats indeed nice to have!
But as you already mentioned in the forum the 'or' think isn't just limited to isEqualTo() so it covers only a part of this issue.

Show
Johannes Zillmann added a comment - 19/Nov/10 3:02 AM Hi Joel, thats indeed nice to have! But as you already mentioned in the forum the 'or' think isn't just limited to isEqualTo() so it covers only a part of this issue.
Hide
Permalink
Yvonne Wang added a comment - 06/Feb/11 8:56 AM

Implemented as org.fest.assertions.condition.AnyOf. Please note this fix is in the FEST-Assert 2.x branch: https://github.com/alexruiz/fest-assert-2.x

Show
Yvonne Wang added a comment - 06/Feb/11 8:56 AM Implemented as org.fest.assertions.condition.AnyOf . Please note this fix is in the FEST-Assert 2.x branch: https://github.com/alexruiz/fest-assert-2.x

People

  • Assignee:
    Yvonne Wang
    Reporter:
    Johannes Zillmann
Vote (0)
Watch (0)

Dates

  • Created:
    18/Nov/10 10:37 AM
    Updated:
    07/Mar/12 4:49 PM
    Resolved:
    06/Feb/11 8:56 AM
  • Atlassian JIRA (v5.2.7#850-sha1:b2af0c8)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.