GrooBe
allows you to use should-be assertions on Groovy unit tests. At the moment we support the following:
-
Equality assertions
shouldBe
andshouldNotBe
shouldEqual
andshouldNotEqual
shouldBeEqual
andshouldNotBeEqual
shouldBeEqualTo
andshouldNotBeEqualTo
-
Instance assertions
- "instance of" tests with
shouldBeA
andshouldBeAn
, with the respectiveshouldNotBeA
andshouldNotBeAn
- "instance of" tests with
-
Comparable assertions
shouldBeGreaterThan
shouldBeLessThan
-
String assertions
shouldStartWith
andshouldNotStartWith
shouldEndWith
andshouldNotEndWith
shouldContain
andshouldNotContain
shouldBeEmpty
andshouldNotBeEmpty
-
Map assertions
shouldHaveKey
andshouldNotHaveKey
shouldHaveValue
andshouldNotHaveValue
shouldHaveEntry
andshouldNotHaveEntry
shouldBeEmpty
andshouldNotBeEmpty
-
Collection assertions
shouldContain
andshouldNotContain
shouldContainSubset
andshouldNotContainSubset
shouldBeEmpty
andshouldNotBeEmpty
Just add GrooBe
as a dependency on your Maven pom.xml
file:
<dependency>
<groupId>com.github.tanob</groupId>
<artifactId>groobe</artifactId>
<version>1.1</version>
</dependency>
Being based on the hamcrest test expressions allows GrooBe
to be used with JUnit or TestNG.
Here is an example of how you use it with JUnit4, there are several other examples in the src/test
directory:
import com.github.tanob.groobe.GrooBe
import org.junit.Before
import org.junit.Test
public class ExampleTest {
@Before
public void before() {
GrooBe.activate()
}
@Test
public void someShouldBeAssertions() {
(2*2).shouldNotBe 5
1.shouldBeAn Integer
"a different string".shouldNotContain "the same string"
}
}
I would like to thank Paul Hammant (http://paulhammant.com/) for all his help and for suggesting the name GrooBe
for the project.
We use a BSD license as you can see in our LICENSE.txt.