開発者!私は統合テスト(OPA5、sapui5)に関するいくつかの質問を持っています。私は2つのビュー(View1.view.xmlとView2.view.xml)を持つシンプルなプロジェクトを作成しました。そして、私は最初のビューでsap.m.Buttonを持っています。このボタンを押すと、2番目のビューに移動します。したがって、私はこの機能をチェックするためにOPA5テストを実装しました。今、私はボタンでユーザのクリックをシミュレートしており、ナビゲーションは適切に動作しています。しかし、ナビゲーションをトリガーした後に可視性View1.view.xmlをチェックしたい場合、私は "テスト合格"結果を得るでしょう!私はテストが非同期的に実行されているので、私はこの結果を持っていると思います。そして、次にテストが終了する瞬間をどうやって捕まえることができますか?なぜ私はview2にナビゲーションをtrigerringした後にview1を見ることができます(統合テスト)
UnexpectedbehaviorJourney.js
QUnit.module("Unexpected behavior");
opaTest("Why do I see View1.view after Navigation was pressed?",
function (Given, When, Then) {
// Arrangements
Given.iStartMyApp();
//Actions
When.onTheAppView.iLookAtTheScreen().
and.iPressNavigateButton();
// Assertions
Then.onTheAppView.iShouldSeeView1AfterTriggeringNavigation();
// and.iTeardownMyAppFrame();
});
UnexpectedBehavior.js
actions : {
iPressNavigateButton : function() {
return this.waitFor({
id : "idButton",
viewName : "View1",
actions: new Press(),
errorMessage : "Button control wasn't pressed"
});
}
},
assertions : {
iShouldSeeView1AfterTriggeringNavigation : function() {
return this.waitFor({
id : "idView1",
viewName : "View1",
success : function() {
ok(true, "Why I can see View1.view?");
},
errorMessage : "Navigation has worked as expected!"
});
}
}
View1.controller.js
return Controller.extend("InvestigateOPA.controller.View1", {
onPress: function() {
this.getOwnerComponent().getRouter().navTo("appView2");
}
});
どうすればこの現象を防ぐことができますか?
ここにconsole.logがあります: sap.ui.getCore()。byId( "View1"); 未定義 so リターン!sap.ui.getCore()。byId( "View1"); 残念なことに常にtrue –
ok、ビューが消されない、またはfalseに設定されている場合、oApp.getCurrentPage()。getId()!== "__component0 --- View1" thatsのAppViewを持っている場合は、 –
上記のコードをチェックすると現在のページが確認されます –