Class JxnUnitTestFailureExpected
- java.lang.Object
-
- JxnUnitTest
-
- JxnUnitTestFailureExpected
-
public class JxnUnitTestFailureExpected extends JxnUnitTest
Variant ofJxnUnitTestused 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_todoofJxnUnitTestFailureExpectedwhich is inherited fromJxnUnitTest.
The following example illustrates how to useJxnUnitTestFailureExpectedin 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
-
-
Field Summary
-
Fields inherited from class JxnUnitTest
ID, itsDoubleEps, itsFloatEps
-
-
Constructor Summary
Constructors Constructor Description JxnUnitTestFailureExpected()Constructs instance.JxnUnitTestFailureExpected(double doubleEps)Constructs instance.JxnUnitTestFailureExpected(double doubleEps, float floatEps)Constructs instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static StringclearAll()Deprecated.replaced byresetAll()Stringreset()Resets the test counters of this instance.static StringresetAll()Resets all static test counters.JxnUnitTestFailureExpectedsetFailureExpected(boolean failureExpected)Sets failure expected (InitiallyitsFailureExpectedis set true and normally not changed).Stringsummary()Returns summary as String.static StringsummaryAll()Returns summary of all tests as String.static StringsummaryAll(boolean doReset)Returns summary of all tests as String and ifdoResetis true, resets all test counters.protected voidupdateFail()Updates counters for failed tests.protected voidupdateTest()Updates counters (for all tests).-
Methods inherited from class JxnUnitTest
arrayStartsWith, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquivalent, assertException, assertException, assertException, assertException, assertException, assertFalse, assertFalse, assertNotNull, assertNotSame, assertNull, assertSame, assertStartsWith, assertStartsWith, assertStartsWith, assertStartsWith, assertTrue, assertTrue, fail, failed, getDoubleEps, getDoubleMaxDiff, getFloatEps, getFloatMaxDiff, ignore, main, ok, setDoubleEps, setEps, setFailIgnore, setFailString, setFloatEps, setIgnore, setOkIgnore, setOkString, setShowHashCode, setVerbose, summary, toString, toString
-
-
-
-
Constructor Detail
-
JxnUnitTestFailureExpected
public JxnUnitTestFailureExpected()
Constructs instance.- See Also:
JxnUnitTest()
-
JxnUnitTestFailureExpected
public JxnUnitTestFailureExpected(double doubleEps)
Constructs instance.- See Also:
JxnUnitTest( double eps )
-
JxnUnitTestFailureExpected
public JxnUnitTestFailureExpected(double doubleEps, float floatEps)Constructs instance.
-
-
Method Detail
-
setFailureExpected
public JxnUnitTestFailureExpected setFailureExpected(boolean failureExpected)
Sets failure expected (InitiallyitsFailureExpectedis set true and normally not changed).
-
reset
public String reset()
Description copied from class:JxnUnitTestResets the test counters of this instance.- Overrides:
resetin classJxnUnitTest
-
resetAll
public static String resetAll()
Resets all static test counters.
-
clearAll
public static String clearAll()
Deprecated.replaced byresetAll()Resets all static test counters.
-
summary
public String summary()
Description copied from class:JxnUnitTestReturns summary as String.- Overrides:
summaryin classJxnUnitTest
-
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 ifdoResetis true, resets all test counters.
-
updateTest
protected void updateTest()
Description copied from class:JxnUnitTestUpdates counters (for all tests).- Overrides:
updateTestin classJxnUnitTest
-
updateFail
protected void updateFail()
Description copied from class:JxnUnitTestUpdates counters for failed tests.- Overrides:
updateFailin classJxnUnitTest
-
-