Fortunately, FEST Assert supports it properly
Let's add dependency to the maven project, by add these XML block to the pop.xml. The code snippet is easy to find by search google with the keywords: "FEST Assert Maven"
<dependency> <groupid>org.easytesting</groupid> <artifactid>fest-assert-core</artifactid> <version>2.0M10</version> </dependency>
Your pom.xlm will be like this
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>SimpleTestWithJava</groupId>
<artifactId>SimpleTestWithJava</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupid>org.easytesting</groupid>
<artifactid>fest-assert-core</artifactid>
<version>2.0M10</version>
</dependency>
</dependencies>
</project>
and the previous script should be changed to
import static org.fest.assertions.api.Assertions.assertThat;
/**
* Created by nhien.truong on 2/27/14.
*/
public class SimpleTestWithFestAssert {
public static void main(String[] args) {
double sum = new Calculator().add(2,3);
assertThat(sum)
.as("result of the add operation")
.isEqualTo(5.5);
}
}
Output:>>
Exception in thread "main" java.lang.AssertionError: [result of the add operation] expected:
<5.5>
but was:
<5.0>
Không có nhận xét nào:
Đăng nhận xét