Bael 1580 2 (#3787)
* BAEL-1580: Changing hamcrest dependency. * BAEL-1580: Adding test scope. * BAEL-1580: Adding comparesEqualTo and notANumber matchers.
This commit is contained in:
parent
9667f061ab
commit
bce01cfff5
|
@ -46,14 +46,14 @@
|
|||
<version>${powermock.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>java-hamcrest</artifactId>
|
||||
<version>2.0.0.0</version>
|
||||
<version>${hamcrest.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -74,6 +74,7 @@
|
|||
|
||||
<!-- testing -->
|
||||
<powermock.version>1.7.0</powermock.version>
|
||||
<hamcrest.version>2.0.0.0</hamcrest.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
|
|
@ -6,8 +6,15 @@ import java.math.BigDecimal;
|
|||
import java.time.LocalDate;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.closeTo;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.lessThan;
|
||||
import static org.hamcrest.Matchers.lessThanOrEqualTo;
|
||||
import static org.hamcrest.Matchers.comparesEqualTo;
|
||||
import static org.hamcrest.Matchers.notANumber;
|
||||
|
||||
public class HamcrestNumberUnitTest {
|
||||
|
||||
|
@ -43,6 +50,19 @@ public class HamcrestNumberUnitTest {
|
|||
assertThat(actual, is(not(closeTo(operand, error))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void given5_whenComparesEqualTo5_thenCorrect() {
|
||||
Integer five = 5;
|
||||
assertThat(five, comparesEqualTo(five));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void given5_whenNotComparesEqualTo7_thenCorrect() {
|
||||
Integer seven = 7;
|
||||
Integer five = 5;
|
||||
assertThat(five, not(comparesEqualTo(seven)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void given7_whenGreaterThan5_thenCorrect() {
|
||||
Integer seven = 7;
|
||||
|
@ -149,4 +169,10 @@ public class HamcrestNumberUnitTest {
|
|||
else return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenNaN_whenIsNotANumber_thenCorrect() {
|
||||
double zero = 0d;
|
||||
assertThat(zero / zero, is(notANumber()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue