import static org.fest.assertions.api.Assertions.*; String actual = "Hello World"; String expected = "Hello World"; assertThat(actual).isEqualTo(expected); import static org.fest.assertions.api.Assertions.*; User actual = new User("John", 25); User expected = new User("John", 25); assertThat(actual).isEqualTo(expected); import static org.fest.assertions.api.Assertions.*; List<String> actualList = Arrays.asList("apple", "banana", "orange"); List<String> expectedList = Arrays.asList("apple", "banana", "orange"); assertThat(actualList).containsExactly(expectedList.toArray()); import static org.fest.assertions.api.Assertions.*; assertThatThrownBy(() -> { throw new IllegalArgumentException("Invalid argument"); }).isInstanceOf(IllegalArgumentException.class) .hasMessageContaining("Invalid argument"); <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> <version>3.21.0</version> <scope>test</scope> </dependency> groovy testImplementation 'org.assertj:assertj-core:3.21.0'


上一篇:
下一篇:
切换中文