これは、APIレベルで作業していることを前提としています。私が間違って読んだら、GUIレベルで作業していると、セレンやワイアのようなものを考えるのがより簡単になります。
TAP結果(テスト用の何らかのプロトコル)を出力する独自の単純なテストフレームワークを作成し、それをgrindまたはTAP2HTMLで解析することを検討しましたか?
1..7
ok 1 - hello world with null value returns 'hello world' string
ok 2 - hello world with bob returns 'hello, bob'
ok 3 - hello world with 123 return 'hello, 123'
ok 4 - hello world with 5K string return hello plus string
ok 5 - special characters
ok 6 - internationalization, fr
ok 7 - internationalization, ja
Looks like you failed 0 tests of 7.
(それはステップ5の後に死亡した場合は、1..7は、何かが間違っているあなたを言うだろう)
出力はストレートASCIIです:
真剣に、TAP出力は次のようになります。あなたは基本的に2つのグローバル、numTestsTotalとnumTestExecutedを持っており、このような関数を記述します:
sub ok (boolean bExpected, string comment) {
if (bExpected) {
print "ok " . numTestsExecuted . " " . comment . "\n";
}else {
print "not ok" . numTeststotal . " " . comment . "\n";
}
numTestsExecuted++;
}
sub eq(int iExpected, int iResult, string comment) {
if (iExpected==iResult) {
print "ok " . numTestsExecuted . " " . comment . "\n";
} else {
print "not ok" . numTestsExecuted . " " . comment . \n";
}
numTestsExecuted++;
}
あなたは、ライブラリ内の定期的なコードを書く、そしてテストアプリがライブラリとテストモジュールが含まれます。
など、TAPの
参照ドキュメントあなたは価値のすべてのタイプのEQをオーバーロードすることができ、および書き込みは、配列を比較することです:はい、あなたがいることを主張することができ http://testanything.org/wiki/index.php/Main_Page
そしてTest::More
をeq()はok()を呼び出すべきです。または、期待どおりの結果と実際の結果を出力に挿入できます。あなた次第。
とにかく、より多くの命令型言語のためのTAPパーサとインタープリタがたくさんあります。
です。 Matt、書式を修正する必要があります。 –