import java.util.Arrays; public class StringUtils { public static String toUpperCase(String str) { return str.toUpperCase(); } public static String reverse(String str) { return new StringBuilder(str).reverse().toString(); } public static String[] split(String str, String delimiter) { return str.split(delimiter); } } import zio.test.Assertion; import zio.test.DefaultRunnableSpec; import zio.test.assert; import zio.test.mock.Expectation; import zio.test.mock.Expectation.value; import zio.test.mock.mockable; import zio.test.mock.mockable1; import zio.test.mock.mockable2; import zio.test.mock.mockable3; import zio.test.mock.mockable4; import zio.test.mock.mockable5; import zio.test.mock.mockable6; import zio.test.mock.mockable9; import zio.test.mock.mockableZio; import zio.test.mock.proxy; import zio.test.mock.recognizer; import zio.test.mock.stub; import zio.test.mock.verify; import zio.test.mock.when_; public class StringUtilsTest extends DefaultRunnableSpec { public spec = suite("StringUtils Test Suite", test("toUpperCase should convert string to uppercase")( assert(StringUtils.toUpperCase("hello")).equalTo("HELLO") ), test("reverse should reverse the input string")( assert(StringUtils.reverse("hello")).equalTo("olleh") ), test("split should split the string on the given delimiter")( assert(StringUtils.split("hello,world", ",")).equalTo(Array("hello", "world")) ) ) def runner() = { val runtime = Runtime.unsafeFromLayer(~~lenzyTest.mocks.mockLayer) // your mocks module, that you need to implement val result = unsafeRun(run(suite)) result } }


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