/** テストドライバ */ class testapp operations public executeAll : () ==> () executeAll() == ( executeVerification(); executeValidation(); ); public executeVerification : () ==> () executeVerification() == ( dcl ts : TestSuite := new TestSuite("Mindstorms NXTライントレース仕様正当性確認テスト"), tr : TestResult := new TestResult(); -- リスナー登録 tr.addListener(new printTestListener()); -- テストケース追加 ts.addTest(new testVerification01("Case 1 - ライン状態判定テスト")); -- テスト実行 ts.run(tr); -- 最終結果表示 if tr.wasSuccessful() = true then def - = new IO().echo("*** All verification tests Passed. ***") in skip else def - = new IO().echo("*** ERROR! ***") in skip ); public executeValidation : () ==> () executeValidation() == ( dcl ts : TestSuite := new TestSuite("Mindstorms NXTライントレース仕様妥当性確認テスト"), tr : TestResult := new TestResult(); -- リスナー登録 tr.addListener(new printTestListener()); -- テストケース追加 ts.addTest(new testValidation01("Case 1 - 右折")); --ts.addTest(new testValidation02("Case 2 - 左折")); -- テスト実行 ts.run(tr); -- 最終結果表示 if tr.wasSuccessful() = true then def - = new IO().echo("*** All validation tests Passed. ***") in skip else def - = new IO().echo("*** ERROR! ***") in skip ); end testapp /** printTestListener : テストの経過と結果をプリントするリスナークラス */ class printTestListener is subclass of TestListener operations public initListener: () ==> () initListener () == skip; public exitListener: () ==> () exitListener () == skip; public addFailure: Test * AssertionFailedError ==> () addFailure (test, failError) == if failError.hasMessage() then print(test.getName() ^ failError.getMessage()) else skip; public addError: Test * Throwable ==> () addError (-, -) == skip; public startTest: Test ==> () startTest (test) == print("Start test - " ^ test.getName()); public endTest: Test ==> () endTest (test) == print("End test - " ^ test.getName()); public print : seq of char ==> () print(str) == def - = new IO().echo(str ^ "\n") in skip; end printTestListener