Class JSpec


  • public final class JSpec
    extends Object
    • Method Detail

      • it

        public static <T> Expectation<T> it​(T o1)
        Works the same way as methods the(Object) or a(Object), but takes generalized instance as parameter. For example you can't use it(12345).shouldBeEqual("12345"); you will get compilation error. You can perform checking only for the same type instances. Valid examples:
        • it(1).shouldNotBeEqual(2)
        • it("a").shouldNotBeEqual("b")
        Not valid examples:
        • it(1L).shouldNotBeEqual(2)
        • it("aaa").shouldNotBeEqual(1)
        Type Parameters:
        T - generic type of expectation
        Parameters:
        o1 - generic instance for checking
        Returns:
        generalized expectation
      • expect

        public static <T> void expect​(Class<T> type,
                                      String message,
                                      Runnable runnable)
        Expect an exception.
        Parameters:
        type - class of exception to expect
        message - message to expect. This can be null
        runnable - instance of java.lang.Runnable to execute
      • expect

        public static <T> void expect​(DifferenceExpectation<T> expectation)
        Expect that the results are different, throw TestException if same.
        Parameters:
        expectation - difference expectation.