プログラムで実行できるテスト スイートを作成しようとしています。(ドキュメントには、IDE をいじってテストを実行させることができると記載されていますが、テストスイートを独自の実行可能なユニットを持つ標準の Ceylon モジュールとしてセットアップするためのより定期的なアプローチのように思えます。また、ドキュメントにはありません。 IDE の方法で実際に行う方法については何も言いません)。
そのため、 createTestRunner関数を使用してTestRunnerを作成しています。この関数は、最初の引数としてTestSourceの Sequential (' ') を取ります。このタイプのエイリアスです:TestSource[]
TestSource
Module|Package|ClassDeclaration|FunctionDeclaration|Class<Anything,Nothing>|FunctionModel<Anything,Nothing>|String
テスト ランナーにテストをフィードするにはどうすればよいですか?
まず、それらをローカル関数に配置してから、テスト ランナーがこれらの関数に何らかの方法でアクセスできるようにするのが最も簡単なようです (これ以上は指定しません)。エイリアスに含まれる型の長いリストには実際のFunctionsTestSource
が含まれていないように見えるため、正しいもののように見える最も近い候補であるFunctionDeclarationを探してみました。
このような関数宣言を行うには、まず、テスト ラッパー関数が実際にどのように見えるかを考えなければなりませんでした。おそらくこのようなものですか?
Anything myTests1 () {
// assert something!
return null;
}
void myTests2 () {
// assert some more things!
}
(ちなみに、これらの関数は型ごとに同等です)
多くのCeylon Herd 精査の後、そのような関数の aFunctionDeclaration
は次のように綴ることができると考えました。
// function name for function declaration:
LIdentifier funName = LIdentifier("myName");
// type of return value for function declaration:
UIdentifier returnTypeName1 = UIdentifier("Anything");
TypeNameWithTypeArguments returnTypeName2 = TypeNameWithTypeArguments(returnTypeName1);
BaseType returnType = BaseType( returnTypeName2 );
// type of parameters for function declaration:
Sequential<Parameter> parameters1 = []; // our test wrapper functions takes no arguments
Parameters parameters2 = Parameters( parameters1 );
Sequence<Parameters> parameterLists = [parameters2];
// the actual function declaration:
FunctionDeclaration myFunctionDeclaration = FunctionDeclaration(
funName,
returnType,
parameterLists
);
だから今、私がしなければならなかったのは、これをcreateTestRunner
関数に与えることだけでした。私はただ入れなければなりませんでしmyFunctionDeclaration
たTestSource[]
:
TestSource myTestSource = myFunctionDeclaration;
TestSource[] mySourceList = [myTestSource];
TestRunner myTestRunner = createTestRunner(mySourceList);
しかし、その最初の行は機能しません。myFunctionDeclaration
タイプ 'FunctionDeclaration' は単にタイプとして渡されませんTestSource
。なぜだめですか?FunctionDeclaration
適切な TestSource タイプではありませんか? のエイリアス定義を見ると、TestSource
可能なタイプのリストにあるようFunctionDeclaration
です。
Module|Package|ClassDeclaration|FunctionDeclaration|Class<Anything,Nothing>|FunctionModel<Anything,Nothing>|String
ここで何が欠けていますか?