unit testing - How to run SAPUI5 Fiori application with mock data -


i have fiori application in local pc , see has model folder bunch of json files mock data. run app in browser mock data cannot find documentation on how this. know parameter sapui5 expecting read data locally instead of odata server?

i not using sap web ide, (which know has option "run mock data") said behind scenes.

thank much. best regards,

with sap web ide, mockserver (which injected when select option "run mock data") automatically started. can manually inside application, recommend able run automated tests application running in mock mode.

you can check brandnew sapui5 walkthrough (step 27) more details on how start mockserver inside application: https://github.com/sap/openui5/tree/master/src/sap.m/test/sap/m/demokit/tutorial/walkthrough/27

the documentation walkthrough released openui5 release 1.30 copied relevant parts here, hope helps! michael

documentation start page (testservice.html): "we modify our copy of index.html file , add new page title distinguish productive start page. since want separate test , productive coding, add second namespace sap.ui.demo.wt.test points test folder , used in testservice.html file.

additionally, switch initialization of component sap.ui.require syntax, because load more additional files required startup of our app. first dependency file called server.js located in test/service folder. replace shell , componentcontainer reference dependencies require statement provides.

the new artifact loaded , implement our local test server called init method before define component. way can catch requests go “real” service , process locally our test server when launching app testservice.html file."

documentation mock server script: "now have extended our test data metadata.xml file can write code initialize server simulate requests instead of real server.

we load mockserver module dependency , create helper object defines init method start server. method called before component initialization in testservice.html file above.

the init method creates mockserver instance same url real service. url in configuration parameter rooturi served our test server instead of real service. next set 2 global configuration settings mockserver instances tell server respond automatically , introduce delay of 1 second imitate typical server response time. otherwise, have call respond method on mockserver manually simulate call.

in order simulate manual backend call can call simulate method on mockserver instance path our newly created metadata.xml. read test data our local file system , set url patterns mimic real service.

finally, call start on omockserver. point, each request url pattern rooturi processed mockserver. if switch index.html file testservice.html file in browser, can see test data displayed local sources again, short delay.

this approach perfect local testing, without network connection. way development not depend on availability of remote server, i.e. run tests. point have 2 different entry pages: 1 real “connected” app (index.html) , 1 local testing (testservice.html)."


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -