public class StringUtilsSpec extends Spec { private StringUtils stringUtils; @Before public void setup() { stringUtils = new StringUtils(); } @Test public void shouldReverseString() { String input = "hello"; String expectedOutput = "olleh"; String output = stringUtils.reverseString(input); should("reverse the input string correctly", output, equalTo(expectedOutput)); } @Test public void shouldThrowExceptionForNullInput() { String input = null; shouldThrow(NullPointerException.class, () -> stringUtils.reverseString(input)); } } <dependency> <groupId>io.specsy</groupId> <artifactId>specsy-core</artifactId> <version>1.0.0</version> <scope>test</scope> </dependency>


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