<dependency> <groupId>com.squareup</groupId> <artifactId>expekt</artifactId> <version>1.2.0</version> </dependency> import static com.squareup.expekt.Expect.*; public class MyLibraryTest { public static void main(String[] args) { describe("MyLibrary", () -> { it("should return true when a valid input is provided", () -> { MyLibrary myLibrary = new MyLibrary(); boolean result = myLibrary.isValidInput("valid"); expect(result).to.be.true(); }); it("should throw an exception when an invalid input is provided", () -> { MyLibrary myLibrary = new MyLibrary(); MyException exception = expectException(MyException.class, () -> { myLibrary.isValidInput("invalid"); }); expect(exception.getMessage()).to.contain("Invalid input"); }); }); run(); } }


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