Skip to content

Add greaterThan and lessThan test framework assertions#619

Merged
asfgit merged 4 commits intoapache:masterfrom
sjcorbett:test-assertions
Apr 6, 2017
Merged

Add greaterThan and lessThan test framework assertions#619
asfgit merged 4 commits intoapache:masterfrom
sjcorbett:test-assertions

Conversation

@sjcorbett
Copy link
Contributor

Each relies on the two objects being compared being instances of the same Comparable<T>.

I also took the opportunity to simplify the logic in TestAssertions.

Copy link
Contributor

@aledsage aledsage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; only one minor comment that needs any attention I think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think UNKNOWN_CONDITION should be included here in the knownConditions.

return actual != null
&& expected != null
&& actual instanceof Comparable
&& actual.getClass().equals(expected.getClass());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should do any coercion, or perhaps even just give it a go to compare! For example, comparing (Integer)1 with (Long)2 might well be possible. However, on balance I think your code is right as it is the simplest (and avoid ClassCastException).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting one. This implementation has already bitten me: "webapp.reqs.perSec.last expected greaterThan 80 but found 96.8063872255489". I'm inclined to leave this as-is until there are more complaints. I do think that this is to restrictive though - actual and expected could be different types if Comparable is implemented by a shared superclass. Don't think it'll be a common problem though.

Sam Corbett added 2 commits April 6, 2017 10:20
Relies on the two objects being compared being instances of
Comparable<T>.
@geomacy
Copy link
Contributor

geomacy commented Apr 6, 2017

LGTM, & @aledsage's comment has been addressed. Will merge.

@asfgit asfgit merged commit c51c69a into apache:master Apr 6, 2017
asfgit pushed a commit that referenced this pull request Apr 6, 2017
Add greaterThan and lessThan test framework assertions

Each relies on the two objects being compared being instances of the same `Comparable<T>`.

I also took the opportunity to simplify the logic in `TestAssertions`.
asfgit pushed a commit to apache/brooklyn-docs that referenced this pull request Apr 6, 2017
Documentation on greaterThan and lessThan test assertions

Accompanies apache/brooklyn-server#619.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments