Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add common non infix assertions #26

Merged
merged 8 commits into from
Feb 19, 2017
Merged

Conversation

MarkusAmshove
Copy link
Owner

@MarkusAmshove MarkusAmshove commented Feb 19, 2017

Collections:

  • shouldBeEmpty()
  • shouldNotBeEmpty()

String/CharSequence:

  • shouldBeEmpty()
  • shouldNotBeEmpty()
  • shouldBeBlank()
  • shouldNotBeBlank()

String?/CharSequence?

  • shouldBeNullOrEmpty()
  • shouldNotBeNullOrEmpty()
  • shouldBeNullOrBlank()
  • shouldNotNullOrBlank()

Nullable types:

  • shouldBeNull()
  • shouldNotBeNull()

Boolean:

  • shouldBeTrue()
  • shouldBefalse()
  • shouldNotBeTrue()
  • shouldNotBeFalse()

Closes #21

@MarkusAmshove MarkusAmshove changed the title Add shouldBeNull and shouldNotBeNull Add common non infix assertions Feb 19, 2017
@MarkusAmshove MarkusAmshove merged commit 52c3ed3 into master Feb 19, 2017
@MarkusAmshove MarkusAmshove deleted the common-non-infix-assertions branch February 19, 2017 17:23
fun Any?.`should be null`() = assertNull(this)
fun Any?.shouldBeNull() = this.`should be null`()

fun Any?.`should not be null`() = assertNotNull(this)
Copy link

Choose a reason for hiding this comment

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

how about assertNotNull("shouldn't be null", this) or something similar?
It could be a lot more descriptive than

java.lang.AssertionError
	at org.junit.Assert.fail(Assert.java:86)
	at org.junit.Assert.assertTrue(Assert.java:41)
	at org.junit.Assert.assertNotNull(Assert.java:712)
	at org.junit.Assert.assertNotNull(Assert.java:722)

Copy link
Owner Author

Choose a reason for hiding this comment

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

Good find, I've opened an issue #88 and will fix this

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.

None yet

2 participants