Class JxnUnitTestFailureExpected


  • public class JxnUnitTestFailureExpected
    extends JxnUnitTest
    Variant of JxnUnitTest used for tests which during test driven developement are expected to fail initially. In test driven developement unit tests are writen prior to the implementation of the methods. Since the implementation initially is missing or is replaced by simple incomplete stubs unit tests will fail in the first place. This failure of the tests for methods without a complete implementation is the expected reaction in this stage of developement. To indicate tests which are not yet expected to pass the respective tests are called on an instance e.g. ut_todo of JxnUnitTestFailureExpected which is inherited from JxnUnitTest.

    The following example illustrates how to use JxnUnitTestFailureExpected in JXN:
    
       ! ut is used for tests which already passed
       ut = @JxnUnitTest();
       ! ut_todo is used for tests which are expected to fail, because of missing or incomplete implementation
       ut_todo = @JxnUnitTestFailureExpected();
       !
       ! Passed Tests:
       ut.assertEquals( 3.14159, PI, 0.00001 )
        = ok (java.lang.String)
       ut.assertEquals( 1.414, sqrt 2, 0.001 )
        = ok (java.lang.String)
       !
       ! The following test initially throws an exception because the method mySquare(double) is not (yet) defined:
       ! $this.test "..." catches the Exception, to avoid that JXN terminates and returns the exception object
       ut_todo.assertEquals( 9., $this.test "mySquare(3.)" )
       ? invokeMethod: identifier mySquare( double ) undefined, wrong number of parameters or not public
        = --failed-- expected: 9.0 (double), found: KmgFormelException: invokeMethod: identifier mySquare( double ) undefined, wrong number of parameters or not public (class KmgFormelException) (java.lang.String)
       !
       ut.summary()
        = ok (2 tests passed) (java.lang.String)
       ut_todo.summary()
        = --- 1 failures expected in 1 tests --- (java.lang.String)
       JxnUnitTestFailureExpected.summaryAll(true)
        = --- 1 failures expected in 3 tests in 2 instance(s) --- (java.lang.String)
    
    
    See Also:
    → test driven developement
    • Constructor Detail

      • JxnUnitTestFailureExpected

        public JxnUnitTestFailureExpected()
        Constructs instance.
        See Also:
        JxnUnitTest()
      • JxnUnitTestFailureExpected

        public JxnUnitTestFailureExpected​(double doubleEps)
        Constructs instance.
        See Also:
        JxnUnitTest( double eps )
    • Method Detail

      • setFailureExpected

        public JxnUnitTestFailureExpected setFailureExpected​(boolean failureExpected)
        Sets failure expected (Initially itsFailureExpected is set true and normally not changed).
      • resetAll

        public static String resetAll()
        Resets all static test counters.
      • clearAll

        public static String clearAll()
        Deprecated.
        replaced by resetAll()
        Resets all static test counters.
      • summaryAll

        public static String summaryAll()
        Returns summary of all tests as String.
      • summaryAll

        public static String summaryAll​(boolean doReset)
        Returns summary of all tests as String and if doReset is true, resets all test counters.
      • updateTest

        protected void updateTest()
        Description copied from class: JxnUnitTest
        Updates counters (for all tests).
        Overrides:
        updateTest in class JxnUnitTest
      • updateFail

        protected void updateFail()
        Description copied from class: JxnUnitTest
        Updates counters for failed tests.
        Overrides:
        updateFail in class JxnUnitTest